hebedich 通过本文主要向大家介绍了二维码生成器在线制作,制作二维码生成器,如何制作二维码生成器,制作二维码生成器下载,二维码生成器怎么制作等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
这个程序不能直接支持 Unicode, 同样不能直接支持任何双字节或多字节字符(包括汉字), 但可以用十六进制转码的方式生成包含 Unicode (或其他任何编码)字符的二维码图形.
如果数据含有UTF-8 Unicode 字符时, 在数据头部加上 BOM (\xEF\xBB\xBF) 即可.
例如:
\xEF\xBB\xBF\xE6\xB1\x89\xE5\xAD\x97
上面的代码表示中文字符 "汉字"
任何 ASCII 字符(\x00 到 \xFF)都可以用十六进制转码方式输入, 也可以用明文输入(如果可以的话), 十六进制转码用 "\x" 开头, 后跟两位十六进制.
例如: \x20 表示空格
纠错等级有4级可选: L,M,Q,H
掩码图形有 8 种可选: 0 到 7 的整数.
已更正的问题: 版本20141113, 当数据中含有双引号时, 有可能导致程序退出.
测试于 Win7 64 位 及 XP 32 位
REM If you want to rewrite the registry to automatically set the console font size to 8X8 pixels, please un-remark the next line.
REM %1 @goto :initCON
@echo off & chcp 437 & mode 200, 200
echo;
echo; QRCODE.CMD
echo;
echo; Author neorobin -- Rewritten in CMD Batch @ Nov. 12, 2014
echo;
echo; Author davidshimjs -- QRCode for Javascript library
echo; See http://www.d-project.com/
echo; See http://jeromeetienne.github.com/jquery-qrcode/
echo;
echo; ---------------------------------------------------------------------
echo; QRCode for JavaScript
echo;
echo; Copyright (c) 2009 Kazuhiko Arase
echo;
echo; URL: http://www.d-project.com/
echo;
echo; Licensed under the MIT license:
echo; http://www.opensource.org/licenses/mit-license.php
echo;
echo; The word "QR Code" is registered trademark of
echo; DENSO WAVE INCORPORATED
echo; http://www.denso-wave.com/qrcode/faqpatent-e.html
echo;
echo; ---------------------------------------------------------------------
echo;
REM ************************************************************
REM *
REM * Main Program
REM *
REM ************************************************************
REM If you want to clear some environment variables to speed up running, you can un-remark the next line.
call :clearVars
setlocal enabledelayedexpansion
call :initGlobalVars
call :quickShow
:main.loop
REM If the data contains Unicode UTF-8 characters, you must add the BOM data header (\xEF\xBB\xBF).
REM set "BOM=\xEF\xBB\xBF"
echo;
set /p "data=Input data:"
if "!data!"=="" goto :main.loop
set "errorCorrectLevel="
set /p "t=Choose a error correct level (L/M/Q/H):"
for %%a in (L:1 M:0 Q:3 H:2) do for /f "tokens=1,2 delims=:" %%v in ("%%a") do if /i "%t%"=="%%v" set "errorCorrectLevel=%%w"
if "%errorCorrectLevel%"=="" set "errorCorrectLevel=1"
REM A - Auto, [0..7] - spec, else random
set /p "mp=Choose a mask pattern between 0 and 7 :"
if /i "!mp!"=="A" (
set "maskPattern="
) else if "!mp!" geq "0" (
if "!mp!" leq "7" (
set /a "maskPattern = !mp:~0,1!"
) else (
set "mp=r"
)
) else (
set "mp=r"
)
if "!mp!"=="r" (
set /a "maskPattern = !random! & 7"
)
call :QRCode.makeCode data errorCorrectLevel maskPattern
goto :main.loop
exit
REM ************************************************************
REM *
REM * Functions
REM *
REM ************************************************************
:QRCode.makeCode data errorCorrectLevel maskPattern
setlocal enabledelayedexpansion
echo; & echo;QRCode.makeCode & echo;
set "data=!%~1!"
set /a "errorCorrectLevel = %~2"
set "maskPattern=!%~3!"
set data
set errorCorrectLevel
set maskPattern
set "oQRCodeModel.dataList="
call :_getTypeNumber TypeNumber data errorCorrectLevel
REM If the initial size of the console is too small to display a large size QR Code image,
REM you can un-remark the next line to auto resize the console window.
REM call :autoResizeScr typeNumber 20
set typeNumber
call :QRCodeModel.addData oQRCodeModel.dataList oQRCodeModel.dataCache data
set oQRCodeModel.dataList
call :QRCodeModel.make oQRCodeModel typeNumber errorCorrectLevel maskPattern
call :paint oQRCodeModel.modules oQRCodeModel.moduleCount
endlocal
exit /b
REM end of :QRCode.makeCode
REM ***
:QRCodeModel.make oQRCodeModel typeNumber errorCorrectLevel specifiedMaskPattern
setlocal enabledelayedexpansion
set "oQRCodeModel.dataList=!%~1.dataList!"
set "oQRCodeModel.dataCache=!%~1.dataCache!"
set /a "typeNumber = %~2, errorCorrectLevel = %~3"
set "BestMaskPattern=!%~4!"
if "!BestMaskPattern!"=="" (
call :QRCodeModel.getBestMaskPattern oQRCodeModel typeNumber errorCorrectLevel BestMaskPattern
)
title QRCODE.CMD typeNumber: %typeNumber%, errorCorrectLevel: %errorCorrectLevel%, BestMaskPattern: %BestMaskPattern%
call :QRCodeModel.makeImpl oQRCodeModel typeNumber 0 BestMaskPattern errorCorrectLevel
(
endlocal
set "%~1.modules=%oQRCodeModel.modules%"
set "%~1.modules.defined=%oQRCodeModel.modules.defined%"
set "%~1.moduleCount=%oQRCodeModel.moduleCount%"
exit /b
)
REM end of :QRCodeModel.make
REM ***
:QRCodeModel.makeImpl oQRCodeModel typeNumber test maskPattern errorCorrectLevel
setlocal enabledelayedexpansion
set /a "typeNumber = %~2, test = %~3, maskPattern = %~4, errorCorrectLevel = %~5"
set "dataList=!%~1.dataList!"
set "dataCache=!%~1.dataCache!"
set /a "moduleCount = typeNumber * 4 + 17"
set "modules="
set /a "iMax= moduleCount * moduleCount, iByteMax = (iMax >> 3) + ^!^!(iMax & 7), iQuadMax = iByteMax << 1"
for /l %%i in (1 1 %iByteMax%) do set "modules=00!modules!"
set "modules.defined=!modules!"
echo;QRCodeModel.setupPositionProbePattern
call :QRCodeModel.setupPositionProbePattern modules 0 0 moduleCount
call :QRCodeModel.setupPositionProbePattern modules "(moduleCount - 7)" 0 moduleCount
call :QRCodeModel.setupPositionProbePattern modules 0 "(moduleCount - 7)" moduleCount
echo;QRCodeModel.setupPositionAdjustPattern
call :QRCodeModel.setupPositionAdjustPattern modules typeNumber moduleCount
echo;QRCodeModel.setupTimingPattern
call :QRCodeModel.setupTimingPattern modules moduleCount
echo;QRCodeModel.setupTypeInfo
call :QRCodeModel.setupTypeInfo modules test maskPattern errorCorrectLevel moduleCount
if !typeNumber! geq 7 (
echo;QRCodeModel.setupTypeNumber
call :QRCodeModel.setupTypeNumber modules test typeNumber moduleCount
)
if "%dataCache%"=="" (
call :QRCodeModel.createData dataCache typeNumber errorCorrectLevel dataList
)
call :QRCodeModel.mapData modules moduleCount dataCache maskPattern
(
endlocal
set "%~1.modules=%modules%"
set "%~1.modules.defined=%modules.defined%"
set "%~1.moduleCount=%moduleCount%"
exit /b
)
REM end of :QRCodeModel.makeImpl
REM ***
:QRCodeModel.getBestMaskPattern oQRCodeModel typeNumber errorCorrectLevel BestMaskPattern
echo; & echo;QRCodeModel.getBestMaskPattern & echo;
setlocal enabledelayedexpansion
set "oQRCodeModel.dataList=!%~1.dataList!"
set "oQRCodeModel.dataCache=!%~1.dataCache!"
set /a "typeNumber = %~2, errorCorrectLevel = %~3"
set /a "minLostPoint = 1 << IMSB ^ -1, pattern = 0"
for /L %%i in (0 1 7) do (
call :QRCodeModel.makeImpl oQRCodeModel typeNumber 1 %%i errorCorrectLevel
call :QRUtil.getLostPoint oQRCodeModel lostPoint
echo;pattern: %%i, lostPoint: !lostPoint!
if !minLostPoint! gtr !lostPoint! (
set /a "minLostPoint = lostPoint, pattern = %%i"
)
)
(
endlocal
set "%~4=%pattern%"
exit /b
)
REM end of :QRCodeModel.getBestMaskPattern
REM ***
:QRUtil.getLostPoint oQRCodeModel.qrCode lostPoint
echo; & echo;QRCodeModel.getLostPoint & echo;
setlocal enabledelayedexpansion
set "modules=!%~1.modules!"
set /a "moduleCount = %~1.moduleCount, lostPoint = 0, rm = moduleCount - 1, cm = rm, m_2 = rm - 1"
set "LEQ=-1-"
set moduleCount
for /L %%r in (0 1 %rm%) do for /L %%c in (0 1 %cm%) do (
set /a "sameCount = 0, ibs = %%c + %%r * moduleCount, iqs = ibs >> 2"
for %%a in (!iqs!) do (
set /a "dark = 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1"
)
for %%L in (-1 0 1) do (
set /a "t = %%r + %%L, t |= moduleCount %LEQ% t"
if !

