首页 > 编程 > BAT > 正文

批处理制作二维码生成器

2020-06-09 14:26:35
字体:
来源:转载
供稿:网友

这个程序不能直接支持 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, 200echo;echo; QRCODE.CMDecho;echo; Author neorobin -- Rewritten in CMD Batch @ Nov. 12, 2014echo;echo; Author davidshimjs -- QRCode for Javascript libraryecho; See http://www.d-project.com/echo; See http://jeromeetienne.github.com/jquery-qrcode/echo;echo; ---------------------------------------------------------------------echo; QRCode for JavaScriptecho;echo; Copyright (c) 2009 Kazuhiko Araseecho;echo; URL: http://www.d-project.com/echo;echo; Licensed under the MIT license:echo; http://www.opensource.org/licenses/mit-license.phpecho;echo; The word "QR Code" is registered trademark ofecho; DENSO WAVE INCORPORATEDecho; http://www.denso-wave.com/qrcode/faqpatent-e.htmlecho;echo; ---------------------------------------------------------------------echo;REM ************************************************************REM *REM * Main ProgramREM *REM ************************************************************REM If you want to clear some environment variables to speed up running, you can un-remark the next line.call :clearVarssetlocal enabledelayedexpansioncall :initGlobalVarscall :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 maskPatterngoto :main.loopexitREM ************************************************************REM *REM * FunctionsREM *REM ************************************************************:QRCode.makeCode data errorCorrectLevel maskPatternsetlocal 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.moduleCountendlocalexit /bREM end of :QRCode.makeCodeREM ***:QRCodeModel.make oQRCodeModel typeNumber errorCorrectLevel specifiedMaskPatternsetlocal enabledelayedexpansionset "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.makeREM ***:QRCodeModel.makeImpl oQRCodeModel typeNumber test maskPattern errorCorrectLevelsetlocal enabledelayedexpansionset /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.setupPositionProbePatterncall :QRCodeModel.setupPositionProbePattern modules 0 0 moduleCountcall :QRCodeModel.setupPositionProbePattern modules "(moduleCount - 7)" 0 moduleCountcall :QRCodeModel.setupPositionProbePattern modules 0 "(moduleCount - 7)" moduleCountecho;QRCodeModel.setupPositionAdjustPatterncall :QRCodeModel.setupPositionAdjustPattern modules typeNumber moduleCountecho;QRCodeModel.setupTimingPatterncall :QRCodeModel.setupTimingPattern modules moduleCountecho;QRCodeModel.setupTypeInfocall :QRCodeModel.setupTypeInfo modules test maskPattern errorCorrectLevel moduleCountif !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.makeImplREM ***:QRCodeModel.getBestMaskPattern oQRCodeModel typeNumber errorCorrectLevel BestMaskPatternecho; & echo;QRCodeModel.getBestMaskPattern & echo;setlocal enabledelayedexpansionset "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.getBestMaskPatternREM ***:QRUtil.getLostPoint oQRCodeModel.qrCode lostPointecho; & echo;QRCodeModel.getLostPoint & echo;setlocal enabledelayedexpansionset "modules=!%~1.modules!"set /a "moduleCount = %~1.moduleCount, lostPoint = 0, rm = moduleCount - 1, cm = rm, m_2 = rm - 1"set "LEQ=-1-"set moduleCountfor /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 !t! geq 0 ( for %%F in (-1 0 1) do ( set /a "t = %%c + %%F, t |= moduleCount %LEQ% t" if !t! geq 0 if "%%L%%F" neq "00" ( set /a "ibs1 = ibs + %%F + %%L * moduleCount, iqs1 = ibs1 >> 2" for %%a in (!iqs1!) do ( set /a "sameCount += ^!(dark ^^ (0x!modules:~%%a,1! >> (3 ^^ (ibs1 & 3)) & 1))" ) ) ) ) ) set /a "lostPoint += (5 - sameCount >> IMSB) & (sameCount - 2)")for /L %%r in (0 1 %m_2%) do for /L %%c in (0 1 %m_2%) do ( set "t=0" set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1" ) set /a "ibs += 1, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 1" ) set /a "ibs += moduleCount, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 2" ) set /a "ibs -= 1, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 3" ) set /a "lostPoint += (^!t | ^!(t - 0xF)) << IMSB >> IMSB & 3")set /a "m_7 = moduleCount - 7"for /L %%r in (0 1 %rm%) do for /L %%c in (0 1 %m_7%) do ( set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2, ibs += 6, lenQuad = (ibs >> 2) - iqs + 1" for /f "tokens=1-2" %%a in ("!iqs! !lenQuad!") do ( set /a "lostPoint += ^!(0x!modules:~%%a,%%b! >> (3 ^^ (ibs & 3)) & 0x7F ^^ 0x5D) << IMSB >> IMSB & 40" ))set /a "m_7 = moduleCount - 7"for /L %%c in (0 1 %cm%) do for /L %%r in (0 1 %m_7%) do ( set "t=0" set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1" ) for /L %%d in (1 1 6) do ( set /a "ibs += moduleCount, iqs = ibs >> 2" for %%a in (!iqs!) do ( set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << %%d" ) ) set /a "lostPoint += ^!(t ^^ 0x5D) << IMSB >> IMSB & 40")set /a "t = moduleCount * moduleCount, iQuadEnd = t / 4 + ^!^!(t %% 4) - 1"set /a "qStep = WORDSIZE / 4, darkCount = 0"for /L %%i in (0 %qStep% %iQuadEnd%) do ( set /a "t = 0x!modules:~%%i,%qStep%!" for /L %%j in (0 1 %IMSB%) do set /a "darkCount += t >> %%j & 1")set /a "lostPoint += (x = 200 * darkCount / (moduleCount * moduleCount) - 100, t = x >> IMSB, (t&-x|~t&x))"( endlocal set "%~2=%lostPoint%" exit /b)REM end of :QRUtil.getLostPointREM ***:_getTypeNumber TypeNumber sText nCorrectLevelsetlocal enabledelayedexpansionset "sText=!%~2!"set /a "nCorrectLevel = %~3, j = nCorrectLevel ^ 1"set "QRCodeLimitLength=17_14_11_7 32_26_20_14 53_42_32_24 78_62_46_34 106_84_60_44 134_106_74_58 154_122_86_64 192_152_108_84 230_180_130_98 271_213_151_119 321_251_177_137 367_287_203_155 425_331_241_177 458_362_258_194 520_412_292_220 586_450_322_250 644_504_364_280 718_560_394_310 792_624_442_338 858_666_482_382 929_711_509_403 1003_779_565_439 1091_857_611_461 1171_911_661_511 1273_997_715_535 1367_1059_751_593 1465_1125_805_625 1528_1190_868_658 1628_1264_908_698 1732_1370_982_742 1840_1452_1030_790 1952_1538_1112_842 2068_1628_1168_898 2188_1722_1228_958 2303_1809_1283_983 2431_1911_1351_1051 2563_1989_1423_1093 2699_2099_1499_1139 2809_2213_1579_1219 2953_2331_1663_1273"call :dataList.getLength QRCodeLimitLength QRCodeLimitLength.lengthset /a "nType = 1"call :strLen sText lengthset "i=0":_getTypeNumber.for_i if %i% geq %QRCodeLimitLength.length% goto :_getTypeNumber.for_i.break set "nLimit=0" call :{} QRCodeLimitLength i QRCodeLimitLength[i] call :[] QRCodeLimitLength[i] j nLimit if %length% leq %nLimit% ( goto :_getTypeNumber.for_i.break ) else ( set /a "nType += 1" ) set /a "i += 1" goto :_getTypeNumber.for_i:_getTypeNumber.for_i.breakif %nType% gtr %QRCodeLimitLength.length% ( call :throwError "Too long data")( endlocal set "%~1=%nType%" exit /b)REM end of :_getTypeNumberREM ***:QRRSBlock.RS_BLOCK_TABLE index arrRtsetlocal enabledelayedexpansionset /a "i = %~1 / 31 + 1, j = %~1 %% 31 + 1"for /f "tokens=%i% delims=;" %%a in ("1_26_19 1_26_16 1_26_13 1_26_9 1_44_34 1_44_28 1_44_22 1_44_16 1_70_55 1_70_44 2_35_17 2_35_13 1_100_80 2_50_32 2_50_24 4_25_9 1_134_108 2_67_43 2_33_15_2_34_16 2_33_11_2_34_12 2_86_68 4_43_27 4_43_19 4_43_15 2_98_78 4_49_31 2_32_14_4_33_15 4_39_13_1_40_14 2_121_97 2_60_38_2_61_39 4_40_18_2_41_19;4_40_14_2_41_15 2_146_116 3_58_36_2_59_37 4_36_16_4_37_17 4_36_12_4_37_13 2_86_68_2_87_69 4_69_43_1_70_44 6_43_19_2_44_20 6_43_15_2_44_16 4_101_81 1_80_50_4_81_51 4_50_22_4_51_23 3_36_12_8_37_13 2_116_92_2_117_93 6_58_36_2_59_37 4_46_20_6_47_21 7_42_14_4_43_15 4_133_107 8_59_37_1_60_38 8_44_20_4_45_21 12_33_11_4_34_12 3_145_115_1_146_116 4_64_40_5_65_41 11_36_16_5_37_17 11_36_12_5_37_13 5_109_87_1_110_88 5_65_41_5_66_42 5_54_24_7_55_25 11_36_12 5_122_98_1_123_99 7_73_45_3_74_46;15_43_19_2_44_20 3_45_15_13_46_16 1_135_107_5_136_108 10_74_46_1_75_47 1_50_22_15_51_23 2_42_14_17_43_15 5_150_120_1_151_121 9_69_43_4_70_44 17_50_22_1_51_23 2_42_14_19_43_15 3_141_113_4_142_114 3_70_44_11_71_45 17_47_21_4_48_22 9_39_13_16_40_14 3_135_107_5_136_108 3_67_41_13_68_42 15_54_24_5_55_25 15_43_15_10_44_16 4_144_116_4_145_117 17_68_42 17_50_22_6_51_23 19_46_16_6_47_17 2_139_111_7_140_112 17_74_46 7_54_24_16_55_25 34_37_13 4_151_121_5_152_122 4_75_47_14_76_48 11_54_24_14_55_25 16_45_15_14_46_16 6_147_117_4_148_118;6_73_45_14_74_46 11_54_24_16_55_25 30_46_16_2_47_17 8_132_106_4_133_107 8_75_47_13_76_48 7_54_24_22_55_25 22_45_15_13_46_16 10_142_114_2_143_115 19_74_46_4_75_47 28_50_22_6_51_23 33_46_16_4_47_17 8_152_122_4_153_123 22_73_45_3_74_46 8_53_23_26_54_24 12_45_15_28_46_16 3_147_117_10_148_118 3_73_45_23_74_46 4_54_24_31_55_25 11_45_15_31_46_16 7_146_116_7_147_117 21_73_45_7_74_46 1_53_23_37_54_24 19_45_15_26_46_16 5_145_115_10_146_116 19_75_47_10_76_48 15_54_24_25_55_25 23_45_15_25_46_16 13_145_115_3_146_116 2_74_46_29_75_47 42_54_24_1_55_25 23_45_15_28_46_16;17_145_115 10_74_46_23_75_47 10_54_24_35_55_25 19_45_15_35_46_16 17_145_115_1_146_116 14_74_46_21_75_47 29_54_24_19_55_25 11_45_15_46_46_16 13_145_115_6_146_116 14_74_46_23_75_47 44_54_24_7_55_25 59_46_16_1_47_17 12_151_121_7_152_122 12_75_47_26_76_48 39_54_24_14_55_25 22_45_15_41_46_16 6_151_121_14_152_122 6_75_47_34_76_48 46_54_24_10_55_25 2_45_15_64_46_16 17_152_122_4_153_123 29_74_46_14_75_47 49_54_24_10_55_25 24_45_15_46_46_16 4_152_122_18_153_123 13_74_46_32_75_47 48_54_24_14_55_25 42_45_15_32_46_16 20_147_117_4_148_118 40_75_47_7_76_48 43_54_24_22_55_25;10_45_15_67_46_16 19_148_118_6_149_119 18_75_47_31_76_48 34_54_24_34_55_25 20_45_15_61_46_16") do ( for /f "tokens=%j%" %%b in ("%%a") do ( set "_=%%b" ))( endlocal set "%~2=%_%" exit /b)REM end of :QRRSBlock.RS_BLOCK_TABLEREM ***:QRRSBlock.getRSBlocks typeNumber errorCorrectLevel listRet setlocal enabledelayedexpansion set /a "typeNumber = %~1, errorCorrectLevel = %~2" call :QRRSBlock.getRsBlockTable typeNumber errorCorrectLevel rsBlock if "%rsBlock%"=="." ( call :throwError "bad rs block @ typeNumber: %typeNumber% /errorCorrectLevel: %errorCorrectLevel%" ) call :length rsBlock "_" len set /a "i_m = len / 3 - 1" set "list=" for /L %%i in (0 1 %i_m%) do ( call :[] rsBlock "(%%i * 3)" count set /a "count_1 = count - 1" call :[] rsBlock "(%%i * 3 + 1)" totalCount call :[] rsBlock "(%%i * 3 + 2)" dataCount for /L %%j in (0 1 !count_1!) do ( set "list=!list!!totalCount!_!dataCount! " ) )( endlocal set "%~3=%list:~0,-1%" exit /b)REM end of :QRRSBlock.getRSBlocksREM ***:QRRSBlock.getRsBlockTable typeNumber errorCorrectLevel arrRtsetlocal enabledelayedexpansionset /a "_t = %~2 & ~3"if %_t%==0 ( set /a "index = ((%~1 - 1) << 2) | (%~2 ^ 1)" call :QRRSBlock.RS_BLOCK_TABLE index ret) else ( set "ret=.")( endlocal set "%~3=%ret%" exit /b)REM end of :QRRSBlock.getRsBlockTableREM ***:QRCodeModel.createData bytes typeNumber errorCorrectLevel dataListsetlocal enabledelayedexpansionset /a "PAD0 = 0xEC, PAD1 = 0x11"set /a "typeNumber = %~2"set "dataList=!%~4!"call :QRRSBlock.getRSBlocks typeNumber errorCorrectLevel rsBlocksset "buffer.buffer="set "buffer.length=0"call :dataList.getLength dataList dataList.lengthset /a "im = dataList.length - 1"for /L %%i in (0 1 %im%) do ( call :{} dataList %%i data call :QRBitBuffer.put buffer.buffer buffer.length MODE_8BIT_BYTE 4 call :QRUtil.getLengthInBits MODE_8BIT_BYTE typeNumber len call :strLen data data.getLength set /a "data.getLength >>= 1" call :QRBitBuffer.put buffer.buffer buffer.length data.getLength len call :QR8bitByte.write buffer.buffer buffer.length data)set "totalDataCount=0"for %%a in (%rsBlocks%) do ( set "t=%%a" set /a "totalDataCount += !t:_=&0|!")set /a "totalDataCount_m8 = totalDataCount << 3"if %buffer.length% gtr %totalDataCount_m8% ( call :throwError "code length overflow. [%buffer.length% gtr %totalDataCount_m8%]")set /a "t = buffer.length + 4"if %t% leq %totalDataCount_m8% ( call :QRBitBuffer.put buffer.buffer buffer.length 0 4)set /a "im = buffer.length & 7 ^ 7"if %im% neq 7 ( for /L %%i in (0 1 %im%) do call :QRBitBuffer.putBit buffer.buffer buffer.length 0):QRCodeModel.createData.while_true if %buffer.length% geq %totalDataCount_m8% goto :QRCodeModel.createData.break call :QRBitBuffer.put buffer.buffer buffer.length PAD0 8 if %buffer.length% geq %totalDataCount_m8% goto :QRCodeModel.createData.break call :QRBitBuffer.put buffer.buffer buffer.length PAD1 8 goto :QRCodeModel.createData.while_true:QRCodeModel.createData.breakcall :QRCodeModel.createBytes bytes buffer.buffer rsBlocks( endlocal set "%~1=%bytes%" exit /b)REM end of :QRCodeModel.createDataREM ***:QRCodeModel.mapData modules moduleCount dataCache maskPatternsetlocal enabledelayedexpansionset "m=!%~1!"set "m.def=!%~1.defined!"set "data=!%~3!"set /a "moduleCount = %~2, moduleCount_1 = moduleCount - 1, "^ "inc = -1, row = moduleCount_1, bitIndex = 7, iQuad = 0, maskPattern = %~4"set "LEQ=-1-"call :strLen data data.quadLenset "$0=~(row+rnk)&1"set "$1=~row&1"set "$2=^!(rnk %% 3)"set "$3=^!((row+rnk) %% 3)"set "$4=~((row>>1)+rnk/3)&1"set "$5=(t=row*rnk,^!(t&1)&^!(t %% 3))"set "$6=(t=row*rnk,~((t&1)+t %% 3)&1)"set "$7=~(row*rnk %% 3+((row+rnk)&1))&1"set /a "col = moduleCount_1":QRCodeModel.mapData.for_col<nul set /p "=%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%COLUMN: %col%/%moduleCount_1% " if %col% leq 0 goto :QRCodeModel.mapData.for_col.end set /a "t = ^!(col ^^ 6) << IMSB >> IMSB, col = t & 5 | ~t & col":QRCodeModel.mapData.while_true for %%c in (0 1) do ( set /a "rnk = col - %%c, ibs = rnk + row * moduleCount, lenL = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad.def = 0x!m.def:~%%a,1! & bit" ) if !quad.def!==0 ( set "dark=0" if !iQuad! lss %data.quadLen% ( for %%i in (!iQuad!) do ( set /a "dark = (0x!data:~%%i,2! >> bitIndex) & 1" ) ) for %%i in (%maskPattern%) do set /a "mask = !$%%i!, dark ^^= mask" set /a "SBB = dark << IMSB >> IMSB, ind = lenL + 1, lenR = iQuadMax - ind" for %%a in (!lenL!) do ( set /a "quad = 0x!m:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!m.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "m=!m:~0,%%A!!%%D!!m:~%%B,%%C!" set "m.def=!m.def:~0,%%A!!%%E!!m.def:~%%B,%%C!" ) set /a "bitIndex -= 1, t = bitIndex >> IMSB, bitIndex = t & 7 | ~t & bitIndex, iQuad += t & 2" ) ) set /a "row += inc, t = row | moduleCount %LEQ% row" if %t% lss 0 ( set /a "row -= inc, inc = -inc" goto :QRCodeModel.mapData.while_true.break ) goto :QRCodeModel.mapData.while_true:QRCodeModel.mapData.while_true.break set /a "col -= 2" goto :QRCodeModel.mapData.for_col:QRCodeModel.mapData.for_col.end( endlocal set "%~1=%m%" set "%~1.defined=%m.def%" exit /b)REM end of :QRCodeModel.mapDataREM ***:dataList.getLength dataList dataList.lengthsetlocal enabledelayedexpansionif "!%~1!"=="." ( set "length=0") else ( set "t=!%~1!" set "t1=!t: =!" call :strLen t len call :strLen t1 len1 set /a "length = len - len1 + 1")( endlocal set "%~2=%length%" exit /b)REM end of :dataList.getLengthREM ***:QR8bitByte.write QRBitBuffer.buffer QRBitBuffer.length QR8bitByte.parsedDatasetlocal enabledelayedexpansionset "buf=!%~1!"set "buf.len=!%~2!"set "pd=!%~3!"call :strLen pd pd.lenset /a "im = pd.len - 2"for /L %%i in (0 2 %im%) do ( set /a "num = 0x!pd:~%%i,2!" call :QRBitBuffer.put buf buf.len num 8)( endlocal set "%~1=%buf%" set "%~2=%buf.len%" exit /b)REM end of :QR8bitByte.writeREM ***:QRCodeModel.createBytes bytes QRBitBuffer.buffer rsBlocks setlocal enabledelayedexpansion set /a "offset = 0, maxDcCount = 0, maxEcCount = 0" set "rsbs=!%~3!" call :dataList.getLength rsbs rMax set /a "rMax -= 1" set "dcdata=" set "ecdata=" for /L %%r in (0 1 %rMax%) do ( call :{} rsbs %%r rsbs[r] call :[] rsbs[r] 1 dcCount call :[] rsbs[r] 0 rsbs[r].tc set /a "ecCount = rsbs[r].tc - dcCount, dcC_1 = dcCount - 1,"^ "t = maxDcCount - dcCount >> IMSB, maxDcCount = t & dcCount | ~t & maxDcCount,"^ "t = maxEcCount - ecCount >> IMSB, maxEcCount = t & ecCount | ~t & maxEcCount" for /L %%i in (0 1 !dcC_1!) do ( set /a "_i = (%%i + offset) << 1" for %%a in (!_i!) do set "dcdata=!dcdata!!%~2:~%%a,2!" ) set "dcdata=!dcdata! " set /a "offset += dcCount" call :QRUtil.getErrorCorrectPolynomial ecCount rsPoly call :strLen rsPoly rsPoly.getLength set /a "shift = rsPoly.getLength - 2 >> 1" call :{} dcdata %%r dcdata[r] call :QRPolynomial.QRPolynomial rawPoly dcdata[r] shift call :QRPolynomial.mod rawPoly rsPoly modPoly call :strLen modPoly modPoly.getLength set /a "ecdata[r].length = rsPoly.getLength - 2" set /a "j = modPoly.getLength - ecdata[r].length" set /a "is = j, im = ecdata[r].length - 2 + j" for /L %%i in (!is! 2 !im!) do ( if %%i geq 0 ( set "ecdata=!ecdata!!modPoly:~%%i,2!" ) else ( set "ecdata=!ecdata!00" ) ) set "ecdata=!ecdata! " ) set "ecdata=%ecdata:~0,-1%" set "dcdata=%dcdata:~0,-1%" set "totalCodeCount=0" for %%a in (%rsbs%) do ( set "t=%%a" set /a "totalCodeCount += !t:_=|0&!" ) set "data=" set /a "im = maxDcCount - 1 << 1" for /L %%i in (0 2 %im%) do ( for /L %%r in (0 1 %rMax%) do ( call :{} dcdata %%r dcdata[r] call :strlen dcdata[r] dcdata[r].length if %%i lss !dcdata[r].length! ( set "data=!data!!dcdata[r]:~%%i,2!" ) ) ) set /a "im = maxEcCount - 1 << 1" for /L %%i in (0 2 %im%) do ( for /L %%r in (0 1 %rMax%) do ( call :{} ecdata %%r ecdata[r] call :strlen ecdata[r] ecdata[r].length if %%i lss !ecdata[r].length! ( set "data=!data!!ecdata[r]:~%%i,2!" ) ) ) set /a "im = totalCodeCount - 2" call :strlen data data.len for /L %%i in (%data.len% 2 %im%) do ( set "data=!data!00" )( endlocal set "%~1=%data%" exit /b)REM end of :QRCodeModel.createBytesREM ***:QRUtil.getErrorCorrectPolynomial errorCorrectLength arrRet setlocal enabledelayedexpansion set "a=01" set /a "im = %~1 - 1 << 1" for /L %%i in (0 2 %im%) do ( set "num=01!EXP_TABLE:~%%i,2!" call :QRPolynomial.QRPolynomial poly num 0 call :QRPolynomial.multiply a poly a )( endlocal set "%~2=%a%" exit /b)REM end of :QRUtil.getErrorCorrectPolynomialREM ***:QRPolynomial.mod this e mod setlocal enabledelayedexpansion set "this=!%~1!" set "e=!%~2!":QRPolynomial.mod.loop call :strLen this this.getLength call :strLen e e.getLength if %this.getLength% lss %e.getLength% ( goto :QRPolynomial.mod.end ) set /a "a = 0x!this:~0,2! << 1, b = 0x!e:~0,2! << 1" for /f "tokens=1-2" %%a in ("!a! !b!") do ( set /a "ratio = 0x!LOG_TABLE:~%%a,2! - 0x!LOG_TABLE:~%%b,2!" ) set "num=%this%" set /a "im = e.getLength - 2" for /L %%i in (0 2 %im%) do ( set /a "e[i] = 0x!e:~%%i,2! << 1" for %%a in (!e[i]!) do ( set /a "P = 0x!LOG_TABLE:~%%a,2! + ratio, t=(P^^P-256)>>IMSB, r=P %% 255, c = ^!r <<IMSB>>IMSB, P = (t & P | ~t & r + ((P>>IMSB ^^ c) & 255)) << 1" ) set /a "ind = %%i + 2, lenR = this.getLength - ind" for %%A in (!P!) do ( set /a "n = 0x!num:~%%i,2! ^^ 0x!EXP_TABLE:~%%A,2!" ) set /a "H4 = n >> 4, L4 = n & 0xF" for /f "tokens=1-4" %%V in ("!ind! !lenR! #!H4! #!L4!") do set "num=!num:~0,%%i!!%%X!!%%Y!!num:~%%V,%%W!" ) call :QRPolynomial.QRPolynomial this num 0 goto :QRPolynomial.mod.loop:QRPolynomial.mod.end( endlocal set "%~3=%this%" exit /b)REM end of :QRPolynomial.modREM ***:QRPolynomial.multiply this e multi setlocal enabledelayedexpansion set "this=!%~1!" set "e=!%~2!" call :strLen this this.getLength call :strLen e e.getLength set /a "len = this.getLength + e.getLength - 2, im = this.getLength - 2, jm = e.getLength - 2" set "num=" for /L %%i in (1 1 %len%) do set "num=!num!0" for /L %%i in (0 2 %im%) do ( for /L %%j in (0 2 %jm%) do ( set /a "a = 0x!this:~%%i,2! << 1, b = 0x!e:~%%j,2! << 1" for /f "tokens=1-2" %%a in ("!a! !b!") do ( set /a "P = 0x!LOG_TABLE:~%%a,2! + 0x!LOG_TABLE:~%%b,2!" ) set /a "t=(P^^P-256)>>IMSB, r=P %% 255, c = ^!r <<IMSB>>IMSB, P = (t & P | ~t & r + ((P>>IMSB ^^ c) & 255)) << 1" set /a "lenL = %%i + %%j, ind = lenL + 2, lenR = len - ind" for /f "tokens=1-2" %%A in ("!lenL! !P!") do ( set /a "n = 0x!num:~%%A,2! ^^ 0x!EXP_TABLE:~%%B,2!" ) set /a "H4 = n >> 4, L4 = n & 0xF" for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "num=!num:~0,%%U!!%%X!!%%Y!!num:~%%V,%%W!" ) ) call :QRPolynomial.QRPolynomial T num 0( endlocal set "%~3=%T%" exit /b)REM end of :QRPolynomial.multiplyREM ***:QRPolynomial.QRPolynomial this.num num shift setlocal enabledelayedexpansion if "!%~2!"=="" ( call :throwError "@QRPolynomial.QRPolynomial num:[%~2] / shift=[%~3]" ) set "num=!%~2!" set "offset=0":QRPolynomial.QRPolynomial.L1 set /a "offs = offset << 1" for %%i in (%offs%) do set "num{offset}=!num:~%%i,2!" call :strLen num num.length set /a "num.length >>= 1" set /a "t = (offset - num.length) & (^! 0x%num{offset}% << IMSB)" if %t% lss 0 ( set /a "offset += 1" goto :QRPolynomial.QRPolynomial.L1 ) set /a "im = num.length - offset - 1" for /L %%i in (0 1 %im%) do ( set /a "i_offset = %%i + offset << 1" for %%a in (!i_offset!) do set "this_num=!this_num!!num:~%%a,2!" ) set /a "shift = %~3" for /L %%i in (1 1 %shift%) do ( set "this_num=!this_num!00" )( endlocal set "%~1=%this_num%" exit /b)REM end of :QRPolynomial.QRPolynomialREM ***:QRCodeModel.setupTypeNumber modules test typeNumber moduleCountsetlocal enabledelayedexpansionset "t=!%~1!"set "t.def=!%~1.defined!"set /a "typeNumber = %~3"call :QRUtil.getBCHTypeNumber bits typeNumberfor /L %%i in (0 1 17) do ( set /a "bit = ^!%~2 & ((bits >> %%i) & 1)" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = (%%i %% 3 + %~4 - 11) + (%%i / 3) * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ))for /L %%i in (0 1 17) do ( set /a "bit = ^!%~2 & ((bits >> %%i) & 1)" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = (%%i / 3) + (%%i %% 3 + %~4 - 11) * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ))( endlocal set "%~1=%t%" set "%~1.defined=%t.def%" exit /b)REM end of :QRCodeModel.setupTypeNumberREM ***:QRCodeModel.setupTypeInfo modules test maskPattern errorCorrectLevel moduleCountsetlocal enabledelayedexpansionset "t=!%~1!"set "t.def=!%~1.defined!"set /a "data = %~4 << 3 | %~3"call :QRUtil.getBCHTypeInfo bits datafor /L %%i in (0 1 14) do ( if %%i lss 6 ( set "r=%%i" ) else if %%i lss 8 ( set /a "r = %%i + 1" ) else ( set /a "r = %~5 - 15 + %%i" ) set /a "bit = ^!%~2 & ((bits >> %%i) & 1)" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = 8 + r * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ))for /L %%i in (0 1 14) do ( if %%i lss 8 ( set /a "c = %~5 - %%i - 1" ) else if %%i lss 9 ( set /a "c = 15 - %%i" ) else ( set /a "c = 14 - %%i" ) set /a "bit = ^!%~2 & ((bits >> %%i) & 1), mod = bit" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = c + 8 * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ))set /a "bit = mod"set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = 8 + (%~5 - 8) * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit")for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!")( endlocal set "%~1=%t%" set "%~1.defined=%t.def%" exit /b)REM end of :QRCodeModel.setupTypeInfoREM ***:QRUtil.getBCHTypeInfo BCHTypeInfo data setlocal enabledelayedexpansion set /a "d = %~2 << 10":QRUtil.getBCHTypeInfo.L1 call :QRUtil.getBCHDigit d.digit d set /a "_d = d.digit - G15.DGT" if !_d! geq 0 ( set /a "d ^= G15 << _d" goto :QRUtil.getBCHTypeInfo.L1 ) set /a "_ = (%~2 << 10 | d) ^ G15_MASK"( endlocal set "%~1=%_%" exit /b)REM end of :QRUtil.getBCHTypeInfoREM ***:QRUtil.getBCHTypeNumber BCHTypeNumber data setlocal enabledelayedexpansion set /a "d = %~2 << 12":QRUtil.getBCHTypeNumber.L1 call :QRUtil.getBCHDigit d.digit d set /a "_d = d.digit - G18.DGT" if !_d! geq 0 ( set /a "d ^= G18 << _d" goto :QRUtil.getBCHTypeNumber.L1 ) set /a "_ = %~2 << 12 | d"( endlocal set "%~1=%_%" exit /b)REM end of :QRUtil.getBCHTypeNumberREM ***:QRUtil.getBCHDigit digit datasetlocal enabledelayedexpansionset /a "t = %~2"if %t% lss 0 ( set "_=%WORDSIZE%") else ( set /a "t <<= 1" set "_=0" for %%i in (16 8 4 2 1) do ( set /a "_i = ~-^!(t >> %%i) & %%i, _ |= _i, t >>= _i" ))( endlocal set "%~1=%_%" exit /b)REM end of :QRUtil.getBCHDigitREM ***:QRCodeModel.setupPositionAdjustPattern modules typeNumber moduleCountsetlocal enabledelayedexpansioncall :QRUtil.PATTERN_POSITION_TABLE "(%~2 - 1)" poscall :length pos "_" pos.lengthset "t=!%~1!"set "t.def=!%~1.defined!"set /a "L_1 = pos.length - 1"for /L %%i in (0 1 %L_1%) do ( for /L %%j in (0 1 %L_1%) do ( call :[] pos %%i row call :[] pos %%j col set /a "ibs = col + row * %~3, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!iqs!) do ( set /a "quad.def = 0x!t.def:~%%a,1! & bit" ) if !quad.def!==0 ( for /L %%r in (-2 1 2) do ( for /L %%c in (-2 1 2) do ( set /a "bit = ^!(%%r & 3 ^^ 2) | ^!(%%c & 3 ^^ 2) | ^!(%%r | %%c), SBB = bit << IMSB >> IMSB" set /a "ibs = col + %%c + (row + %%r) * %~3, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ) ) ) ) ))( endlocal set "%~1=%t%" set "%~1.defined=%t.def%" exit /b)REM end of :QRCodeModel.setupPositionAdjustPatternREM ***:{} list index vRetsetlocal enabledelayedexpansionset "T=!%~1!"set /a "i = %~2"if %i% leq 0 ( for /f %%a in ("%T%") do set "_=%%a" goto :{}.End) set /a "i1 = i + 1":{}.Loop1 if %i1% gtr 31 ( for /f "tokens=31*" %%a in ("%T%") do set "T=%%b" set /a "i1 -= 31" goto :{}.Loop1 ) for /f "tokens=%i1%" %%a in ("%T%") do set "_=%%a":{}.End( endlocal set "%~3=%_%" exit /b)REM end of :{}REM ***:[] array index vrtsetlocal enabledelayedexpansionset "_="set /a "t=%~2 + 1"if "!%~1!" neq "." ( for /f "tokens=%t% delims=_" %%a in ("!%~1!") do set "_=%%a")( endlocal set "%~3=%_%" exit /b)REM end of :[]REM ***:length list delim lensetlocal enabledelayedexpansionif "!%~1!"=="." ( set "_=0") else ( set /a "_=1+(!%~1:%~2=&0)+1+(0&!)")( endlocal set "%~3=%_%" exit /b)REM end of :lengthREM ***:QRUtil.PATTERN_POSITION_TABLE index arrRtsetlocal enabledelayedexpansionset /a "t=%~1, p=t-31"if %t% leq 0 ( set "_=.") else if %p% leq 0 ( for /f "tokens=%t%" %%a in ("6_18 6_22 6_26 6_30 6_34 6_22_38 6_24_42 6_26_46 6_28_50 6_30_54 6_32_58 6_34_62 6_26_46_66 6_26_48_70 6_26_50_74 6_30_54_78 6_30_56_82 6_30_58_86 6_34_62_90 6_28_50_72_94 6_26_50_74_98 6_30_54_78_102 6_28_54_80_106 6_32_58_84_110 6_30_58_86_114 6_34_62_90_118 6_26_50_74_98_122 6_30_54_78_102_126 6_26_52_78_104_130 6_30_56_82_108_134 6_34_60_86_112_138") do ( set "_=%%a" )) else ( for /f "tokens=%p%" %%a in ("6_30_58_86_114_142 6_34_62_90_118_146 6_30_54_78_102_126_150 6_24_50_76_102_128_154 6_28_54_80_106_132_158 6_32_58_84_110_136_162 6_26_54_82_110_138_166 6_30_58_86_114_142_170") do ( set "_=%%a" ))( endlocal set "%~2=%_%" exit /b)REM end of :QRUtil.PATTERN_POSITION_TABLEREM ***:QRUtil.getLengthInBits mode type lensetlocal enabledelayedexpansionset /a "_m = %~1, t = %~2, @11=10,@12=9,@14=8,@18=8, @21=12,@22=11,@24=16,@28=10, @31=14,@32=13,@34=16,@38=12,"^ "a=t-1,b=t-10,c=t-27,d=t-41, _t = (a^b)>>IMSB&1 | (b^c)>>IMSB&2 | (c^d)>>IMSB&3"if %_t%==0 ( call :throwError "ERROR type: %t%") else ( set "_=!@%_t%%_m%!")( endlocal set "%~3=%_%" exit /b)REM end of :QRUtil.getLengthInBitsREM ***:throwError errInfo color CF echo; & echo; & echo;ERROR & echo; & echo; %~1 <nul set /p "=Any key to exit..." >nul pause EXITexit /bREM ***:QRCodeModel.setupTimingPattern modules moduleCount setlocal enabledelayedexpansion set "t=!%~1!" set "t.def=!%~1.defined!" set /a "_m = %~2 - 9" for /L %%r in (8 1 %_m%) do ( set /a "ibs = 6 + %%r * %~2, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!iqs!) do ( set /a "quad.def = 0x!t.def:~%%a,1! & bit" ) if !quad.def!==0 ( set /a "bit = ~%%r & 1" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = 6 + %%r * %~2, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ) ) ) for /L %%c in (8 1 %_m%) do ( set /a "ibs = %%c + 6 * %~2, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!iqs!) do ( set /a "quad.def = 0x!t.def:~%%a,1! & bit" ) if !quad.def!==0 ( set /a "bit = ~%%c & 1" set /a "SBB = bit << IMSB >> IMSB, "^ "ibs = %%c + 6 * %~2, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ) ) )( endlocal set "%~1=%t%" set "%~1.defined=%t.def%" exit /b)REM end of :QRCodeModel.setupTimingPatternREM ***:QRCodeModel.setupPositionProbePattern modules row col moduleCount setlocal enabledelayedexpansion set "t=!%~1!" set "t.def=!%~1.defined!" set "lss=-" & set "LEQ=-1-" for /L %%r in (-1 1 7) do ( set /a "_r = %~2 + %%r, SBB = _r %LEQ% -1 | %~4 %LEQ% _r" if !SBB! geq 0 ( for /L %%c in (-1 1 7) do ( set /a "_c = %~3 + %%c, SBB = _c %LEQ% -1 | %~4 %LEQ% _c" if !SBB! geq 0 ( set /a "SBB = ( ( 0 %LEQ% %%r & %%r %LEQ% 6 & (^!%%c | ^!(%%c - 6)) << IMSB ) | ( 0 %LEQ% %%c & %%c %LEQ% 6 & (^!%%r | ^!(%%r - 6)) << IMSB ) | ( 2 %LEQ% %%r & %%r %LEQ% 4 & 2 %LEQ% %%c & %%c %LEQ% 4) ) >> IMSB, "^ "ibs = _c + _r * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^^ (ibs & 3))" for %%a in (!lenL!) do ( set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^ "quad.def = 0x!t.def:~%%a,1! | bit" ) for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do ( set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!" set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!" ) ) ) ) )( endlocal set "%~1=%t%" set "%~1.defined=%t.def%" exit /b)REM end of :QRCodeModel.setupPositionProbePatternREM ***:paint modules moduleCount test setlocal enabledelayedexpansion if "%~3" neq "" (set /a "test = %~3") else set "test=0" echo; color 0F & echo; set "BLACK= " & set "WHITE=%ASCII219%" for %%i in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do ( set "bits=" for /L %%j in (3 -1 0) do ( set /a "b = 0x%%i >> %%j & 1" set "bits=!bits!!b!" ) set "bits=!bits:0=%WHITE%!" set "H2B=!H2B!"%%i=!bits:1=%BLACK%!" " ) echo; set "w_quietZone=1" set /a "w = %~2 - 1, w1 = w_quietZone * 2 + %~2" set "quietZone=" & for /L %%i in (1 1 !w_quietZone!) do set "quietZone=!quietZone!%WHITE%" for /L %%i in (1 1 !w_quietZone!) do (for /L %%j in (1 1 !w1!) do <nul set /p "=%WHITE%") & echo; for /L %%i in (0 1 !w!) do ( set /a "ibs = %~2 * %%i, iqs = ibs >> 2, quadLen = ((ibs + %~2 - 1) >> 2) - iqs + 1, ibs &= 3" for /f "tokens=1-2" %%s in ("!iqs! !quadLen!") do ( set "_t=!%~1:~%%s,%%t!" if %test%==1 set "t.defined=!%~1.defined:~%%s,%%t!" ) for %%a in (%H2B%) do ( set "_t=!_t:%%~a!" if %test%==1 set "t.defined=!t.defined:%%~a!" ) if %test%==1 ( set /a "im = (quadLen << 2) - 1" set "t=" for /L %%i in (0 1 !im!) do ( if "!t.defined:~%%i,1!"=="%BLACK%" ( set "t=!t!!_t:~%%i,1!" ) else ( set "t=!t!*" ) ) ) else ( set "t=!_t!" ) for /f "tokens=1-2" %%s in ("!ibs! !%~2!") do echo;!quietZone!!t:~%%s,%%t!!quietZone! ) for /L %%i in (1 1 !w_quietZone!) do (for /L %%j in (1 1 !w1!) do <nul set /p "=%WHITE%") & echo; endlocal exit /bREM end of :paintREM ***:QRBitBuffer.put QRBitBuffer.buffer QRBitBuffer.length num lengthsetlocal enabledelayedexpansionset "_b=!%~1!"set "_L=!%~2!"set /a "im = %~4 - 1"for /L %%i in (0 1 %im%) do ( call :QRBitBuffer.putBit _b _L "((%~3 >> (im - %%i)) & 1)")( endlocal set "%~1=%_b%" set "%~2=%_L%" exit /b)REM end of :QRBitBuffer.putREM ***:QRBitBuffer.putBit QRBitBuffer.buffer QRBitBuffer.length bit setlocal enabledelayedexpansion set "_b=!%~1!" call :strLen _b _buf_len set /a "_buf_len >>= 1" set /a "_L = %~2, bufIndex = _L >> 3, bit = %~3" if %_buf_len% leq %bufIndex% ( set "_b=%_b%00" ) if %bit%==1 ( set /a "lenL = bufIndex << 1, ind = lenL + 2, lenR = (_buf_len << 1) - ind" for %%i in (!lenL!) do set /a "_byte = (0x!_b:~%%i,2!) | (0x80 >> (_L & 7))" set /a "H4 = _byte >> 4, L4 = _byte & 0xF" for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "_b=!_b:~0,%%U!!%%X!!%%Y!!_b:~%%V,%%W!" ) set /a "_L += 1"( endlocal set "%~1=%_b%" set "%~2=%_L%" exit /b)REM end of :QRBitBuffer.putBitREM ***:QRCodeModel.addData QRCodeModel.dataList QRCodeModel.dataCache datasetlocal enabledelayedexpansionset "dataList=!%~1!"set "data=!%~3!"call :QR8bitByte.parsedData data parsedDataif "%dataList%"=="" (set "dataList=!parsedData!") else (set "dataList=%dataList% !parsedData!")( endlocal set "%~1=%dataList%" set "%~2=" exit /b)REM end of :QRCodeModel.addDataREM ***:QR8bitByte.parsedData str parsedData( setlocal enabledelayedexpansion set "ASCII_20_7E=01234567890123456789012345678901 ^!"#$%%^&'(^)*+,-./0123456789:;^<=^>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^^^^_`abcdefghijklmnopqrstuvwxyz{^|}~" for /L %%i in (0x20 1 0x7e) do ( set /a "H4 = %%i >> 4, L4 = %%i & 0xF" for /f "tokens=1-2" %%U in ("#!H4! #!L4!") do set "hex=!%%U!!%%V!" if "!ASCII_20_7E:~%%i,1!"=="^" ( set "_^=5E" ) else if "!ASCII_20_7E:~%%i,1!"=="*" ( REM set _*=!hex! ) else ( for %%a in ("!ASCII_20_7E:~%%i,1!") do ( if "%%~a" lss "a" ( if "%%~a"=="!" ( set "_^!=21" ) else ( set _%%~a=!hex! ) ) else if "%%~a" leq "Z" ( for /f "delims=ABCDEFGHIJKLMNOPQRSTUVWXYZ" %%b in ("%%~a") do set #%%~a=!hex! for /f "delims=abcdefghijklmnopqrstuvwxyz" %%b in ("%%~a") do set _%%~a=!hex! ) else ( set _%%~a=!hex! ) ) ) ) REM set "_*=42" & set "_?=63" & rem * and ? are wildcard, the above code does not generate rem the corresponding variables, but also unnecessary set "t=" call :strLen "%~1" iEnd set /a "iEnd -= 1, next = 0" for /L %%i in (0 1 !iEnd!) do ( if %%i geq !next! ( set "isEscape=0" if /i "!%~1:~%%i,2!"=="/x" ( set /a "isEscape = 1, A = %%i + 2, B = A + 1" for %%n in (!A! !B!) do ( if "!%~1:~%%n,1!"=="" ( set "isEscape=0" ) else if "!%~1:~%%n,1!"==";" ( set "isEscape=0" ) else ( for /f "delims=0123456789abcdefABCDEF" %%b in ("!%~1:~%%n,1!") do ( set "isEscape=0" ) ) ) if !isEscape! equ 1 ( for %%n in (!A!) do ( set "t=!t!!%~1:~%%n,2!" set /a "next = %%i + 4" ) ) ) if !isEscape! equ 0 ( for /f delims^=^ eol^= %%j in ("!%~1:~%%i,1!") do ( if "%%j"=="!" ( set "t=!t!21" ) else if "%%j"=="*" ( set "t=!t!2A" ) else if "%%j"=="?" ( set "t=!t!3F" ) else ( if "%%j"=="=" ( set "t=!t!3D" ) else if "%%j" lss "a" ( set "t=!t!!_%%j!" ) else if "%%j" leq "Z" ( for /f "delims=ABCDEFGHIJKLMNOPQRSTUVWXYZ" %%b in ("%%j") do set "t=!t!!#%%j!" for /f "delims=abcdefghijklmnopqrstuvwxyz" %%b in ("%%j") do set "t=!t!!_%%j!" ) else ( set "t=!t!!_%%j!" ) ) ) ) ) ))( endlocal set "%~2=%t%" exit /b)REM end of :QR8bitByte.parsedDataREM ***:strLen str len( setlocal enabledelayedexpansion set "len=0" & set "T=!%~1!#" for %%i in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do if "!T:~%%i!" neq "" set /a "len |= %%i" & set "T=!T:~%%i!")( endlocal set "%~2=%len%" exit /b)REM end of :strLenREM ***:QRMath.glog n vRet setlocal enabledelayedexpansion set /a "n = %~1, i = n << 1" if %n% lss 1 ( call :throwError "@QRMath.glog n:[%~1]" ) for %%i in (%i%) do set "ret=!LOG_TABLE:~%%i,2!"( endlocal set "%~2=%ret%" exit /b)REM end of :QRMath.glogREM ***:QRMath.gexp n vRet setlocal enabledelayedexpansion set /a "n=%~1, t = (n^^n-256)>>IMSB, r=n %% 255, c = ^!r <<IMSB>>IMSB, i = (t & n | ~t & r + ((n>>IMSB ^^ c) & 255)) << 1" for %%i in (%i%) do set "ret=!EXP_TABLE:~%%i,2!"( endlocal set "%~2=%ret%" exit /b)REM end of :QRMath.gexpREM ***:init.LOG_TABLE LOG_TABLE setlocal enabledelayedexpansion set "T=" for /L %%i in (0 1 255) do set "T=!T!.." call :strlen T LOG_TABLE_LEN for /L %%i in (0 1 254) do ( set /a "_i = %%i << 1, H4 = %%i >> 4, L4 = %%i & 0xF" for %%a in (!_i!) do set /a "lenL = 0x!EXP_TABLE:~%%a,2! << 1" set /a "ind = lenL + 2, lenR = LOG_TABLE_LEN - ind" for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "T=!T:~0,%%U!!%%X!!%%Y!!T:~%%V,%%W!" )( endlocal set "%~1=%T%" exit /b)REM end of :init.LOG_TABLEREM ***:init.EXP_TABLE EXP_TABLE setlocal enabledelayedexpansion set "ET=" for /L %%i in (0 1 7) do ( set /a "t = 1 << %%i, H4 = t >> 4, L4 = t & 0xF" for /f "tokens=1-2" %%X in ("#!H4! #!L4!") do ( set "ET=!ET!!%%X!!%%Y!" ) ) for /L %%i in (8 1 255) do ( set /a "i_4 = %%i - 4 << 1, i_5 = %%i - 5 << 1, i_6 = %%i - 6 << 1, i_8 = %%i - 8 << 1" for /f "tokens=1-4" %%a in ("!i_4! !i_5! !i_6! !i_8!") do ( set /a "t = 0x!ET:~%%a,2! ^^ 0x!ET:~%%b,2! ^^ 0x!ET:~%%c,2! ^^ 0x!ET:~%%d,2!" set /a "H4 = t >> 4, L4 = t & 0xF" for /f "tokens=1-2" %%X in ("#!H4! #!L4!") do set "ET=!ET!!%%X!!%%Y!" ) )( endlocal set "%~1=%ET%" exit /b)REM end of :init.EXP_TABLEREM ***:autoResizeScr typeNumber marginsetlocalfor /f "tokens=1-2 delims=:" %%a in ('mode ^| find /i "s:" ^| find /i "n"') do set /a "%%a=%%b"set /a "moduleCount = %~1 * 4 + 17"set /a "sizeMin = moduleCount + %~2"set /a "resize = Lines - sizeMin | Columns - sizeMin"set /a "Lines = (t = Lines - sizeMin >> IMSB, t & sizeMin | ~t & Lines)"set /a "Columns = (t = Columns - sizeMin >> IMSB, t & sizeMin | ~t & Columns)"if %resize% lss 0 mode %Columns%, %Lines%endlocalexit /bREM end of :autoResizeScrREM ***:clearVarsset "Path=%SystemRoot%/system32"for /f "delims==" %%a in ('set') do ( if /i "%%a" neq "Path" set "%%a=")exit /bREM end of :clearVarsREM ***:getBackSpaceAndASCII219call :getASCII219>nul copy 219.chr /b + 13.chr /b 219_CR.chr /b<219_CR.chr set /p "ASCII219="for %%N in (13 219 219_CR) do del %%N.chrcall :getBackSpace BSexit /bREM end of :getBackSpaceAndASCII219REM ***:getASCII219setlocalset ^"genchr=(^ for %%N in (13 219) do if not exist %%N.chr (^ makecab /d compress=off /d reserveperdatablocksize=26 /d reserveperfoldersize=%%N 0.tmp %%N.chr ^>nul^&^ type %%N.chr ^| ((for /l %%n in (1 1 38) do pause)^>nul^&findstr "^^" ^>%%N.temp)^&^ ^>nul copy /y %%N.temp /a %%N.chr /b^&^ del %%N.temp^ )^)^&^del 0.tmp^"for %%N in (13 219) do (del /f /q /a %%N.chr >nul 2>&1)type nul >0.tmpcmd /q /v:on /c "%genchr%"endlocalexit /bREM end of :getASCII219REM ***:getBackSpace vRetfor /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "%~1=%%a"exit /bREM end of :getBackSpaceREM ***:quickShowsetlocalset "modules=FE44313AFBEA776CB43FC13E02CA360F524F2DD06E9322A555E5CE966FABB75A517E1715F2C11455DBAFFCAFF0EF0F878202EC13D33C414E1C672B2907FAAAAAAAAAAAAAAAAAFE0016CF14C94D13137500C7033FFF6840F897070C4AFAD29F33B324C2CD720CF14BED1585F5A250D740B3511151B0347AFE2E3766265B0A0DB73511A388221747342F4714195737584599A05A25595D295C80A8A7B45218D6E66DBEC36FB71F581718448E0C5A08A2DBEEB431751102E4886420DC5D2E6A4F2D2BA29ACD92E974F2B616CF2C7FF587F11ACC3296904AA42CE7BE107DD8C6508FF4B56DDCB643B90F2CBB87341D09514F9900660FAC6DFED9FCFF398BF8A44010C74EFAC54D29C7FAB2892A083FAB1DDCABC91C11F15E4D7142DA51F3F918FFD9D3BFF6301F852752BE76C760DC98C35549361A710C1260A0C0081BE4EDC20990F7237BBEA7ACBE31385162DB8D84F413A667BFFB315749B8B1F4BA8370F6A94A56815E2110CDFF93DB7E53992C6E54342D9FC0F9DB1487E5A6565BEFB5960896F6BD10B0853B57D1BD280DCA2CFECD5CD482ED67CF5E928D9B382490CE27B0C833E267247418C51826E8B17AA3FF7D640C69E73B3214917C84513AB7B0CE2561C173EE71289A42140369271B31F4C581D800EC0D6019DBC1CAFD6C44E2B1B8E40055EB12EB967FDBAFF8FADAF975A8FD1C7800C70AF2C418A54602B5AD6A0B40AB3FD8AA571B0811B8AFD1925AD1C3FEDE7FC6B20FACB8AFC826487C7A73A4009CD7B06DD9F6F63E732648A6566A918E4CC953435B73BDF325BECF3C37BC9FEF9820FC56DB7737759618C611AD879402D1830DB031051F423EB19D3C721B02F96FA65FCA1EB7DFD15A25AC9A463C07C45D5048879FFA6A064F00D575082C195BE3DC86D746B76CED6B748CE6086536CAE8D9B6C076B3ACF0A19CDCBBD6C8DDEFDB3B787E72F4BB8F484C94A92DF233A348FACBFD16F121C452CC8D663269EFBEFB78000EE1C9084D2DFCD820BF49B48B3A5BE10AD3C571387473D9CFFFECBEFBB54DFC805D01450672458131C53FA841AA4830ABDB546B105B19D194659146F7F1CBA2E0EFFBC3EFB6FA8F8DD108A0D6016D1D454AB2E8F29A910A060263412F05EBAF920F143B12B124FEE936636A62FCFFA49100"set /a "moduleCount = 17 + 4 * 16"call :paint modules moduleCountendlocalexit /bREM end of :quickShowREM ***:delRegsetlocal enabledelayedexpansionset "s=!time:~-4,1!":delReg.loopset /a "elapse = (1!time:~-4,1! - s) %% 10"if %elapse% lss 2 goto :delReg.loop>nul reg delete HKCU/Console/QRCODE_CMD /fendlocalexit /bREM end of :delRegREM ***:initGlobalVarsfor /l %%i in (7 8 127) do set /a "_=1<<%%i>>%%i>>1, IMSB=_&%%i|~_&IMSB"set /a "WORDSIZE = IMSB + 1"set /a "MODE_NUMBER = 1 << 0, MODE_ALPHA_NUM = 1 << 1, MODE_8BIT_BYTE = 1 << 2, MODE_KANJI = 1 << 3"set /a "G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)"set /a "G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)"set /a "G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)"call :QRUtil.getBCHDigit G18.DGT G18call :QRUtil.getBCHDigit G15.DGT G15call :getBackSpaceAndASCII219for %%i in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do ( set /a "i = 0x%%i" set "#!i!=%%i")call :init.EXP_TABLE EXP_TABLEcall :init.LOG_TABLE LOG_TABLEexit /bREM end of :initGlobalVarsREM ***:initCON@echo offfor %%a in ( FontSize:00080008 FontFamily:00000030 WindowSize:00C800C8 ScreenColors:0000000f CodePage:000001b5 ScreenBufferSize:00C800C8) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do ( >nul reg add HKCU/Console/QRCODE_CMD /v %%b /t reg_dword /d 0x%%c /f)start "QRCODE_CMD" /max "%ComSpec%" /c "%~0" REM & (call :delReg) & exitREM end of :initCON
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表