Board logo

标题: [游戏娱乐] QR code generator for CMD 二维码生成器 [打印本页]

作者: neorobin    时间: 2014-11-12 23:23     标题: QR code generator for CMD 二维码生成器

本帖最后由 neorobin 于 2014-11-15 12:50 编辑

这个程序不能直接支持 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 的整数.

2014/11/15
已更正的问题: 版本20141113, 当数据中含有双引号时, 有可能导致程序退出.

测试于 Win7 64 位 及 XP 32 位
  1. REM If you want to rewrite the registry to automatically set the console font size to 8X8 pixels, please un-remark the next line.
  2. REM %1 @goto :initCON
  3. @echo off & chcp 437 & mode 200, 200
  4. echo;
  5. echo;  QRCODE.CMD
  6. echo;
  7. echo;  Author neorobin  -- Rewritten in CMD Batch @ Nov. 12, 2014
  8. echo;
  9. echo;  Author davidshimjs -- QRCode for Javascript library
  10. echo;  See http://www.d-project.com/
  11. echo;  See http://jeromeetienne.github.com/jquery-qrcode/
  12. echo;
  13. echo;  ---------------------------------------------------------------------
  14. echo;  QRCode for JavaScript
  15. echo;
  16. echo;  Copyright (c) 2009 Kazuhiko Arase
  17. echo;
  18. echo;  URL: http://www.d-project.com/
  19. echo;
  20. echo;  Licensed under the MIT license:
  21. echo;  http://www.opensource.org/licenses/mit-license.php
  22. echo;
  23. echo;  The word "QR Code" is registered trademark of
  24. echo;  DENSO WAVE INCORPORATED
  25. echo;  http://www.denso-wave.com/qrcode/faqpatent-e.html
  26. echo;
  27. echo;  ---------------------------------------------------------------------
  28. echo;
  29. REM ************************************************************
  30. REM *
  31. REM *                       Main Program
  32. REM *
  33. REM ************************************************************
  34. REM If you want to clear some environment variables to speed up running, you can un-remark the next line.
  35. call :clearVars
  36. setlocal enabledelayedexpansion
  37. call :initGlobalVars
  38. call :quickShow
  39. :main.loop
  40.   REM If the data contains Unicode UTF-8 characters, you must add the BOM data header (\xEF\xBB\xBF).
  41.   REM set "BOM=\xEF\xBB\xBF"
  42.   echo;
  43.   set /p "data=Input data:"
  44.   if "!data!"=="" goto :main.loop
  45.   set "errorCorrectLevel="
  46.   set /p "t=Choose a error correct level (L/M/Q/H):"
  47.   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"
  48.   if "%errorCorrectLevel%"=="" set "errorCorrectLevel=1"
  49.   REM A - Auto, [0..7] - spec, else random
  50.   set /p "mp=Choose a mask pattern between 0 and 7 :"
  51.   if /i "!mp!"=="A" (
  52.     set "maskPattern="
  53.   ) else if "!mp!" geq "0" (
  54.     if "!mp!" leq "7" (
  55.       set /a "maskPattern = !mp:~0,1!"
  56.     ) else (
  57.       set "mp=r"
  58.     )
  59.   ) else (
  60.     set "mp=r"
  61.   )
  62.   if "!mp!"=="r" (
  63.     set /a "maskPattern = !random! & 7"
  64.   )
  65.   call :QRCode.makeCode data errorCorrectLevel maskPattern
  66. goto :main.loop
  67. exit
  68. REM ************************************************************
  69. REM *
  70. REM *                        Functions
  71. REM *
  72. REM ************************************************************
  73. :QRCode.makeCode data errorCorrectLevel maskPattern
  74. setlocal enabledelayedexpansion
  75.   echo; & echo;QRCode.makeCode & echo;
  76.   set "data=!%~1!"
  77.   set /a "errorCorrectLevel = %~2"
  78.   set "maskPattern=!%~3!"
  79.   set data
  80.   set errorCorrectLevel
  81.   set maskPattern
  82.   set "oQRCodeModel.dataList="
  83.   call :_getTypeNumber TypeNumber data errorCorrectLevel
  84.   REM If the initial size of the console is too small to display a large size QR Code image,
  85.   REM you can un-remark the next line to auto resize the console window.
  86.   REM call :autoResizeScr typeNumber 20
  87.   set typeNumber
  88.   call :QRCodeModel.addData oQRCodeModel.dataList oQRCodeModel.dataCache data
  89.   set oQRCodeModel.dataList
  90.   call :QRCodeModel.make oQRCodeModel typeNumber errorCorrectLevel maskPattern
  91.   call :paint oQRCodeModel.modules oQRCodeModel.moduleCount
  92. endlocal
  93. exit /b
  94. REM end of :QRCode.makeCode
  95. REM ***
  96. :QRCodeModel.make oQRCodeModel typeNumber errorCorrectLevel specifiedMaskPattern
  97. setlocal enabledelayedexpansion
  98. set "oQRCodeModel.dataList=!%~1.dataList!"
  99. set "oQRCodeModel.dataCache=!%~1.dataCache!"
  100. set /a "typeNumber = %~2, errorCorrectLevel = %~3"
  101. set "BestMaskPattern=!%~4!"
  102. if "!BestMaskPattern!"=="" (
  103.   call :QRCodeModel.getBestMaskPattern oQRCodeModel typeNumber errorCorrectLevel BestMaskPattern
  104. )
  105. title QRCODE.CMD  typeNumber: %typeNumber%, errorCorrectLevel: %errorCorrectLevel%, BestMaskPattern: %BestMaskPattern%
  106. call :QRCodeModel.makeImpl oQRCodeModel typeNumber 0 BestMaskPattern errorCorrectLevel
  107. (
  108.   endlocal
  109.   set "%~1.modules=%oQRCodeModel.modules%"
  110.   set "%~1.modules.defined=%oQRCodeModel.modules.defined%"
  111.   set "%~1.moduleCount=%oQRCodeModel.moduleCount%"
  112.   exit /b
  113. )
  114. REM end of :QRCodeModel.make
  115. REM ***
  116. :QRCodeModel.makeImpl oQRCodeModel typeNumber test maskPattern errorCorrectLevel
  117. setlocal enabledelayedexpansion
  118. set /a "typeNumber = %~2, test = %~3, maskPattern = %~4, errorCorrectLevel = %~5"
  119. set "dataList=!%~1.dataList!"
  120. set "dataCache=!%~1.dataCache!"
  121. set /a "moduleCount = typeNumber * 4 + 17"
  122. set "modules="
  123. set /a "iMax= moduleCount * moduleCount, iByteMax = (iMax >> 3) + ^!^!(iMax & 7), iQuadMax = iByteMax << 1"
  124. for /l %%i in (1 1 %iByteMax%) do set "modules=00!modules!"
  125. set "modules.defined=!modules!"
  126. echo;QRCodeModel.setupPositionProbePattern
  127. call :QRCodeModel.setupPositionProbePattern modules 0 0 moduleCount
  128. call :QRCodeModel.setupPositionProbePattern modules "(moduleCount - 7)" 0 moduleCount
  129. call :QRCodeModel.setupPositionProbePattern modules 0 "(moduleCount - 7)" moduleCount
  130. echo;QRCodeModel.setupPositionAdjustPattern
  131. call :QRCodeModel.setupPositionAdjustPattern modules typeNumber moduleCount
  132. echo;QRCodeModel.setupTimingPattern
  133. call :QRCodeModel.setupTimingPattern modules moduleCount
  134. echo;QRCodeModel.setupTypeInfo
  135. call :QRCodeModel.setupTypeInfo modules test maskPattern errorCorrectLevel moduleCount
  136. if !typeNumber! geq 7 (
  137.   echo;QRCodeModel.setupTypeNumber
  138.   call :QRCodeModel.setupTypeNumber modules test typeNumber moduleCount
  139. )
  140. if "%dataCache%"=="" (
  141.   call :QRCodeModel.createData dataCache typeNumber errorCorrectLevel dataList
  142. )
  143. call :QRCodeModel.mapData modules moduleCount dataCache maskPattern
  144. (
  145.   endlocal
  146.   set "%~1.modules=%modules%"
  147.   set "%~1.modules.defined=%modules.defined%"
  148.   set "%~1.moduleCount=%moduleCount%"
  149.   exit /b
  150. )
  151. REM end of :QRCodeModel.makeImpl
  152. REM ***
  153. :QRCodeModel.getBestMaskPattern oQRCodeModel typeNumber errorCorrectLevel BestMaskPattern
  154. echo; & echo;QRCodeModel.getBestMaskPattern & echo;
  155. setlocal enabledelayedexpansion
  156. set "oQRCodeModel.dataList=!%~1.dataList!"
  157. set "oQRCodeModel.dataCache=!%~1.dataCache!"
  158. set /a "typeNumber = %~2, errorCorrectLevel = %~3"
  159. set /a "minLostPoint = 1 << IMSB ^ -1, pattern = 0"
  160. for /L %%i in (0 1 7) do (
  161.   call :QRCodeModel.makeImpl oQRCodeModel typeNumber 1 %%i errorCorrectLevel
  162.   call :QRUtil.getLostPoint oQRCodeModel lostPoint
  163.   echo;pattern: %%i, lostPoint: !lostPoint!
  164.   if !minLostPoint! gtr !lostPoint! (
  165.     set /a "minLostPoint = lostPoint, pattern = %%i"
  166.   )
  167. )
  168. (
  169.   endlocal
  170.   set "%~4=%pattern%"
  171.   exit /b
  172. )
  173. REM end of :QRCodeModel.getBestMaskPattern
  174. REM ***
  175. :QRUtil.getLostPoint oQRCodeModel.qrCode lostPoint
  176. echo; & echo;QRCodeModel.getLostPoint & echo;
  177. setlocal enabledelayedexpansion
  178. set "modules=!%~1.modules!"
  179. set /a "moduleCount = %~1.moduleCount, lostPoint = 0, rm = moduleCount - 1, cm = rm, m_2 = rm - 1"
  180. set "LEQ=-1-"
  181. set moduleCount
  182. for /L %%r in (0 1 %rm%) do for /L %%c in (0 1 %cm%) do (
  183.   set /a "sameCount = 0, ibs = %%c + %%r * moduleCount, iqs = ibs >> 2"
  184.   for %%a in (!iqs!) do (
  185.     set /a "dark = 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1"
  186.   )
  187.   for %%L in (-1 0 1) do (
  188.     set /a "t = %%r + %%L, t |= moduleCount %LEQ% t"
  189.     if !t! geq 0 (
  190.       for %%F in (-1 0 1) do (
  191.         set /a "t = %%c + %%F, t |= moduleCount %LEQ% t"
  192.         if !t! geq 0 if "%%L%%F" neq "00" (
  193.           set /a "ibs1 = ibs + %%F + %%L * moduleCount, iqs1 = ibs1 >> 2"
  194.           for %%a in (!iqs1!) do (
  195.             set /a "sameCount += ^!(dark ^^ (0x!modules:~%%a,1! >> (3 ^^ (ibs1 & 3)) & 1))"
  196.           )
  197.         )
  198.       )
  199.     )
  200.   )
  201.   set /a "lostPoint += (5 - sameCount >> IMSB) & (sameCount - 2)"
  202. )
  203. for /L %%r in (0 1 %m_2%) do for /L %%c in (0 1 %m_2%) do (
  204.   set "t=0"
  205.   set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2"
  206.   for %%a in (!iqs!) do (
  207.     set /a "t |= 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1"
  208.   )
  209.   set /a "ibs += 1, iqs = ibs >> 2"
  210.   for %%a in (!iqs!) do (
  211.     set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 1"
  212.   )
  213.   set /a "ibs += moduleCount, iqs = ibs >> 2"
  214.   for %%a in (!iqs!) do (
  215.     set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 2"
  216.   )
  217.   set /a "ibs -= 1, iqs = ibs >> 2"
  218.   for %%a in (!iqs!) do (
  219.     set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << 3"
  220.   )
  221.   set /a "lostPoint += (^!t | ^!(t - 0xF)) << IMSB >> IMSB & 3"
  222. )
  223. set /a "m_7 = moduleCount - 7"
  224. for /L %%r in (0 1 %rm%) do for /L %%c in (0 1 %m_7%) do (
  225.   set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2, ibs += 6, lenQuad = (ibs >> 2) - iqs + 1"
  226.   for /f "tokens=1-2" %%a in ("!iqs! !lenQuad!") do (
  227.     set /a "lostPoint += ^!(0x!modules:~%%a,%%b! >> (3 ^^ (ibs & 3)) & 0x7F ^^ 0x5D) << IMSB >> IMSB & 40"
  228.   )
  229. )
  230. set /a "m_7 = moduleCount - 7"
  231. for /L %%c in (0 1 %cm%) do for /L %%r in (0 1 %m_7%) do (
  232.   set "t=0"
  233.   set /a "ibs = %%c + %%r * moduleCount, iqs = ibs >> 2"
  234.   for %%a in (!iqs!) do (
  235.     set /a "t |= 0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1"
  236.   )
  237.   for /L %%d in (1 1 6) do (
  238.     set /a "ibs += moduleCount, iqs = ibs >> 2"
  239.     for %%a in (!iqs!) do (
  240.       set /a "t |= (0x!modules:~%%a,1! >> (3 ^^ (ibs & 3)) & 1) << %%d"
  241.     )
  242.   )
  243.   set /a "lostPoint += ^!(t ^^ 0x5D) << IMSB >> IMSB & 40"
  244. )
  245. set /a "t = moduleCount * moduleCount, iQuadEnd = t / 4 + ^!^!(t %% 4) - 1"
  246. set /a "qStep = WORDSIZE / 4, darkCount = 0"
  247. for /L %%i in (0 %qStep% %iQuadEnd%) do (
  248.   set /a "t = 0x!modules:~%%i,%qStep%!"
  249.   for /L %%j in (0 1 %IMSB%) do set /a "darkCount += t >> %%j & 1"
  250. )
  251. set /a "lostPoint += (x = 200 * darkCount / (moduleCount * moduleCount) - 100, t = x >> IMSB, (t&-x|~t&x))"
  252. (
  253.   endlocal
  254.   set "%~2=%lostPoint%"
  255.   exit /b
  256. )
  257. REM end of :QRUtil.getLostPoint
  258. REM ***
  259. :_getTypeNumber TypeNumber sText nCorrectLevel
  260. setlocal enabledelayedexpansion
  261. set "sText=!%~2!"
  262. set /a "nCorrectLevel = %~3, j = nCorrectLevel ^ 1"
  263. 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"
  264. call :dataList.getLength QRCodeLimitLength QRCodeLimitLength.length
  265. set /a "nType = 1"
  266. call :strLen sText length
  267. set "i=0"
  268. :_getTypeNumber.for_i
  269.   if %i% geq %QRCodeLimitLength.length% goto :_getTypeNumber.for_i.break
  270.   set "nLimit=0"
  271.   call :{} QRCodeLimitLength i QRCodeLimitLength[i]
  272.   call :[] QRCodeLimitLength[i] j nLimit
  273.   if %length% leq %nLimit% (
  274.     goto :_getTypeNumber.for_i.break
  275.   ) else (
  276.     set /a "nType += 1"
  277.   )
  278.   set /a "i += 1"
  279.   goto :_getTypeNumber.for_i
  280. :_getTypeNumber.for_i.break
  281. if %nType% gtr %QRCodeLimitLength.length% (
  282.   call :throwError "Too long data"
  283. )
  284. (
  285.   endlocal
  286.   set "%~1=%nType%"
  287.   exit /b
  288. )
  289. REM end of :_getTypeNumber
  290. REM ***
  291. :QRRSBlock.RS_BLOCK_TABLE index arrRt
  292. setlocal enabledelayedexpansion
  293. set /a "i = %~1 / 31 + 1, j = %~1 %% 31 + 1"
  294. 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 (
  295.   for /f "tokens=%j%" %%b in ("%%a") do (
  296.     set "_=%%b"
  297.   )
  298. )
  299. (
  300.   endlocal
  301.   set "%~2=%_%"
  302.   exit /b
  303. )
  304. REM end of :QRRSBlock.RS_BLOCK_TABLE
  305. REM ***
  306. :QRRSBlock.getRSBlocks typeNumber errorCorrectLevel listRet
  307.   setlocal enabledelayedexpansion
  308.   set /a "typeNumber = %~1, errorCorrectLevel = %~2"
  309.   call :QRRSBlock.getRsBlockTable typeNumber errorCorrectLevel rsBlock
  310.   if "%rsBlock%"=="." (
  311.     call :throwError "bad rs block @ typeNumber: %typeNumber% /errorCorrectLevel: %errorCorrectLevel%"
  312.   )
  313.   call :length rsBlock "_" len
  314.   set /a "i_m = len / 3 - 1"
  315.   set "list="
  316.   for /L %%i in (0 1 %i_m%) do (
  317.     call :[] rsBlock "(%%i * 3)" count
  318.     set /a "count_1 = count - 1"
  319.     call :[] rsBlock "(%%i * 3 + 1)" totalCount
  320.     call :[] rsBlock "(%%i * 3 + 2)" dataCount
  321.     for /L %%j in (0 1 !count_1!) do (
  322.       set "list=!list!!totalCount!_!dataCount! "
  323.     )
  324.   )
  325. (
  326.   endlocal
  327.   set "%~3=%list:~0,-1%"
  328.   exit /b
  329. )
  330. REM end of :QRRSBlock.getRSBlocks
  331. REM ***
  332. :QRRSBlock.getRsBlockTable typeNumber errorCorrectLevel arrRt
  333. setlocal enabledelayedexpansion
  334. set /a "_t = %~2 & ~3"
  335. if %_t%==0 (
  336.   set /a "index = ((%~1 - 1) << 2) | (%~2 ^ 1)"
  337.   call :QRRSBlock.RS_BLOCK_TABLE index ret
  338. ) else (
  339.   set "ret=."
  340. )
  341. (
  342.   endlocal
  343.   set "%~3=%ret%"
  344.   exit /b
  345. )
  346. REM end of :QRRSBlock.getRsBlockTable
  347. REM ***
  348. :QRCodeModel.createData bytes typeNumber errorCorrectLevel dataList
  349. setlocal enabledelayedexpansion
  350. set /a "PAD0 = 0xEC, PAD1 = 0x11"
  351. set /a "typeNumber = %~2"
  352. set "dataList=!%~4!"
  353. call :QRRSBlock.getRSBlocks typeNumber errorCorrectLevel rsBlocks
  354. set "buffer.buffer="
  355. set "buffer.length=0"
  356. call :dataList.getLength dataList dataList.length
  357. set /a "im = dataList.length - 1"
  358. for /L %%i in (0 1 %im%) do (
  359.   call :{} dataList %%i data
  360.   call :QRBitBuffer.put buffer.buffer buffer.length MODE_8BIT_BYTE 4
  361.   call :QRUtil.getLengthInBits MODE_8BIT_BYTE typeNumber len
  362.   call :strLen data data.getLength
  363.   set /a "data.getLength >>= 1"
  364.   call :QRBitBuffer.put buffer.buffer buffer.length data.getLength len
  365.   call :QR8bitByte.write buffer.buffer buffer.length data
  366. )
  367. set "totalDataCount=0"
  368. for %%a in (%rsBlocks%) do (
  369.   set "t=%%a"
  370.   set /a "totalDataCount += !t:_=&0|!"
  371. )
  372. set /a "totalDataCount_m8 = totalDataCount << 3"
  373. if %buffer.length% gtr %totalDataCount_m8% (
  374.   call :throwError "code length overflow. [%buffer.length% gtr %totalDataCount_m8%]"
  375. )
  376. set /a "t = buffer.length + 4"
  377. if %t% leq %totalDataCount_m8% (
  378.   call :QRBitBuffer.put buffer.buffer buffer.length 0 4
  379. )
  380. set /a "im = buffer.length & 7 ^ 7"
  381. if %im% neq 7 (
  382.   for /L %%i in (0 1 %im%) do call :QRBitBuffer.putBit buffer.buffer buffer.length 0
  383. )
  384. :QRCodeModel.createData.while_true
  385.   if %buffer.length% geq %totalDataCount_m8% goto :QRCodeModel.createData.break
  386.   call :QRBitBuffer.put buffer.buffer buffer.length PAD0 8
  387.   if %buffer.length% geq %totalDataCount_m8% goto :QRCodeModel.createData.break
  388.   call :QRBitBuffer.put buffer.buffer buffer.length PAD1 8
  389.   goto :QRCodeModel.createData.while_true
  390. :QRCodeModel.createData.break
  391. call :QRCodeModel.createBytes bytes buffer.buffer rsBlocks
  392. (
  393.   endlocal
  394.   set "%~1=%bytes%"
  395.   exit /b
  396. )
  397. REM end of :QRCodeModel.createData
  398. REM ***
  399. :QRCodeModel.mapData modules moduleCount dataCache maskPattern
  400. setlocal enabledelayedexpansion
  401. set "m=!%~1!"
  402. set "m.def=!%~1.defined!"
  403. set "data=!%~3!"
  404. set /a "moduleCount = %~2, moduleCount_1 = moduleCount - 1, "^
  405.   "inc = -1, row = moduleCount_1, bitIndex = 7, iQuad = 0, maskPattern = %~4"
  406. set "LEQ=-1-"
  407. call :strLen data data.quadLen
  408. set "$0=~(row+rnk)&1"
  409. set "$1=~row&1"
  410. set "$2=^!(rnk %% 3)"
  411. set "$3=^!((row+rnk) %% 3)"
  412. set "$4=~((row>>1)+rnk/3)&1"
  413. set "$5=(t=row*rnk,^!(t&1)&^!(t %% 3))"
  414. set "$6=(t=row*rnk,~((t&1)+t %% 3)&1)"
  415. set "$7=~(row*rnk %% 3+((row+rnk)&1))&1"
  416. set /a "col = moduleCount_1"
  417. :QRCodeModel.mapData.for_col
  418. <nul set /p "=%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%%BS%COLUMN: %col%/%moduleCount_1%  "
  419.   if %col% leq 0 goto :QRCodeModel.mapData.for_col.end
  420.     set /a "t = ^!(col ^^ 6) << IMSB >> IMSB, col = t & 5 | ~t & col"
  421. :QRCodeModel.mapData.while_true
  422.       for %%c in (0 1) do (
  423.         set /a "rnk = col - %%c, ibs = rnk + row * moduleCount, lenL = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))"
  424.         for %%a in (!lenL!) do (
  425.           set /a "quad.def = 0x!m.def:~%%a,1! & bit"
  426.         )
  427.         if !quad.def!==0 (
  428.           set "dark=0"
  429.           if !iQuad! lss %data.quadLen% (
  430.             for %%i in (!iQuad!) do (
  431.               set /a "dark = (0x!data:~%%i,2! >> bitIndex) & 1"
  432.             )
  433.           )
  434.           for %%i in (%maskPattern%) do set /a "mask = !$%%i!, dark ^^= mask"
  435.           set /a "SBB = dark << IMSB >> IMSB, ind = lenL + 1, lenR = iQuadMax - ind"
  436.           for %%a in (!lenL!) do (
  437.             set /a "quad = 0x!m:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  438.                 "quad.def = 0x!m.def:~%%a,1! | bit"
  439.           )
  440.           for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  441.             set "m=!m:~0,%%A!!%%D!!m:~%%B,%%C!"
  442.             set "m.def=!m.def:~0,%%A!!%%E!!m.def:~%%B,%%C!"
  443.           )
  444.           set /a "bitIndex -= 1, t = bitIndex >> IMSB, bitIndex = t & 7 | ~t & bitIndex, iQuad += t & 2"
  445.         )
  446.       )
  447.       set /a "row += inc, t = row | moduleCount %LEQ% row"
  448.       if %t% lss 0 (
  449.         set /a "row -= inc, inc = -inc"
  450.         goto :QRCodeModel.mapData.while_true.break
  451.       )
  452.     goto :QRCodeModel.mapData.while_true
  453. :QRCodeModel.mapData.while_true.break
  454.   set /a "col -= 2"
  455.   goto :QRCodeModel.mapData.for_col
  456. :QRCodeModel.mapData.for_col.end
  457. (
  458.   endlocal
  459.   set "%~1=%m%"
  460.   set "%~1.defined=%m.def%"
  461.   exit /b
  462. )
  463. REM end of :QRCodeModel.mapData
  464. REM ***
  465. :dataList.getLength dataList dataList.length
  466. setlocal enabledelayedexpansion
  467. if "!%~1!"=="." (
  468.   set "length=0"
  469. ) else (
  470.   set "t=!%~1!"
  471.   set "t1=!t: =!"
  472.   call :strLen t len
  473.   call :strLen t1 len1
  474.   set /a "length = len - len1 + 1"
  475. )
  476. (
  477.   endlocal
  478.   set "%~2=%length%"
  479.   exit /b
  480. )
  481. REM end of :dataList.getLength
  482. REM ***
  483. :QR8bitByte.write QRBitBuffer.buffer QRBitBuffer.length QR8bitByte.parsedData
  484. setlocal enabledelayedexpansion
  485. set "buf=!%~1!"
  486. set "buf.len=!%~2!"
  487. set "pd=!%~3!"
  488. call :strLen pd pd.len
  489. set /a "im = pd.len - 2"
  490. for /L %%i in (0 2 %im%) do (
  491.   set /a "num = 0x!pd:~%%i,2!"
  492.   call :QRBitBuffer.put buf buf.len num 8
  493. )
  494. (
  495.   endlocal
  496.   set "%~1=%buf%"
  497.   set "%~2=%buf.len%"
  498.   exit /b
  499. )
  500. REM end of :QR8bitByte.write
  501. REM ***
  502. :QRCodeModel.createBytes bytes QRBitBuffer.buffer rsBlocks
  503.   setlocal enabledelayedexpansion
  504.   set /a "offset = 0, maxDcCount = 0, maxEcCount = 0"
  505.   set "rsbs=!%~3!"
  506.   call :dataList.getLength rsbs rMax
  507.   set /a "rMax -= 1"
  508.   set "dcdata="
  509.   set "ecdata="
  510.   for /L %%r in (0 1 %rMax%) do (
  511.     call :{} rsbs %%r rsbs[r]
  512.     call :[] rsbs[r] 1 dcCount
  513.     call :[] rsbs[r] 0 rsbs[r].tc
  514.     set /a "ecCount = rsbs[r].tc - dcCount, dcC_1 = dcCount - 1,"^
  515.     "t = maxDcCount - dcCount >> IMSB, maxDcCount = t & dcCount | ~t & maxDcCount,"^
  516.     "t = maxEcCount - ecCount >> IMSB, maxEcCount = t & ecCount | ~t & maxEcCount"
  517.     for /L %%i in (0 1 !dcC_1!) do (
  518.       set /a "_i = (%%i + offset) << 1"
  519.       for %%a in (!_i!) do set "dcdata=!dcdata!!%~2:~%%a,2!"
  520.     )
  521.     set "dcdata=!dcdata! "
  522.     set /a "offset += dcCount"
  523.     call :QRUtil.getErrorCorrectPolynomial ecCount rsPoly
  524.     call :strLen rsPoly rsPoly.getLength
  525.     set /a "shift = rsPoly.getLength - 2 >> 1"
  526.     call :{} dcdata %%r dcdata[r]
  527.     call :QRPolynomial.QRPolynomial rawPoly dcdata[r] shift
  528.     call :QRPolynomial.mod rawPoly rsPoly modPoly
  529.     call :strLen modPoly modPoly.getLength
  530.     set /a "ecdata[r].length = rsPoly.getLength - 2"
  531.     set /a "j = modPoly.getLength - ecdata[r].length"
  532.     set /a "is = j, im = ecdata[r].length - 2 + j"
  533.     for /L %%i in (!is! 2 !im!) do (
  534.       if %%i geq 0 (
  535.         set "ecdata=!ecdata!!modPoly:~%%i,2!"
  536.       ) else (
  537.         set "ecdata=!ecdata!00"
  538.       )
  539.     )
  540.     set "ecdata=!ecdata! "
  541.   )
  542.   set "ecdata=%ecdata:~0,-1%"
  543.   set "dcdata=%dcdata:~0,-1%"
  544.   set "totalCodeCount=0"
  545.   for %%a in (%rsbs%) do (
  546.     set "t=%%a"
  547.     set /a "totalCodeCount += !t:_=|0&!"
  548.   )
  549.   set "data="
  550.   set /a "im = maxDcCount - 1 << 1"
  551.   for /L %%i in (0 2 %im%) do (
  552.     for /L %%r in (0 1 %rMax%) do (
  553.       call :{} dcdata %%r dcdata[r]
  554.       call :strlen dcdata[r] dcdata[r].length
  555.       if %%i lss !dcdata[r].length! (
  556.         set "data=!data!!dcdata[r]:~%%i,2!"
  557.       )
  558.     )
  559.   )
  560.   set /a "im = maxEcCount - 1 << 1"
  561.   for /L %%i in (0 2 %im%) do (
  562.     for /L %%r in (0 1 %rMax%) do (
  563.       call :{} ecdata %%r ecdata[r]
  564.       call :strlen ecdata[r] ecdata[r].length
  565.       if %%i lss !ecdata[r].length! (
  566.         set "data=!data!!ecdata[r]:~%%i,2!"
  567.       )
  568.     )
  569.   )
  570.   set /a "im = totalCodeCount - 2"
  571.   call :strlen data data.len
  572.   for /L %%i in (%data.len% 2 %im%) do (
  573.     set "data=!data!00"
  574.   )
  575. (
  576.   endlocal
  577.   set "%~1=%data%"
  578.   exit /b
  579. )
  580. REM end of :QRCodeModel.createBytes
  581. REM ***
  582. :QRUtil.getErrorCorrectPolynomial errorCorrectLength arrRet
  583.   setlocal enabledelayedexpansion
  584.   set "a=01"
  585.   set /a "im = %~1 - 1 << 1"
  586.   for /L %%i in (0 2 %im%) do (
  587.     set "num=01!EXP_TABLE:~%%i,2!"
  588.     call :QRPolynomial.QRPolynomial poly num 0
  589.     call :QRPolynomial.multiply a poly a
  590.   )
  591. (
  592.   endlocal
  593.   set "%~2=%a%"
  594.   exit /b
  595. )
  596. REM end of :QRUtil.getErrorCorrectPolynomial
  597. REM ***
  598. :QRPolynomial.mod this e mod
  599.   setlocal enabledelayedexpansion
  600.   set "this=!%~1!"
  601.   set "e=!%~2!"
  602. :QRPolynomial.mod.loop
  603.   call :strLen this this.getLength
  604.   call :strLen e e.getLength
  605.   if %this.getLength% lss %e.getLength% (
  606.     goto :QRPolynomial.mod.end
  607.   )
  608.   set /a "a = 0x!this:~0,2! << 1, b = 0x!e:~0,2! << 1"
  609.   for /f "tokens=1-2" %%a in ("!a! !b!") do (
  610.     set /a "ratio = 0x!LOG_TABLE:~%%a,2! - 0x!LOG_TABLE:~%%b,2!"
  611.   )
  612.   set "num=%this%"
  613.   set /a "im = e.getLength - 2"
  614.   for /L %%i in (0 2 %im%) do (
  615.     set /a "e[i] = 0x!e:~%%i,2! << 1"
  616.     for %%a in (!e[i]!) do (
  617.       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"
  618.     )
  619.     set /a "ind = %%i + 2, lenR = this.getLength - ind"
  620.     for %%A in (!P!) do (
  621.       set /a "n = 0x!num:~%%i,2! ^^ 0x!EXP_TABLE:~%%A,2!"
  622.     )
  623.     set /a "H4 = n >> 4, L4 = n & 0xF"
  624.     for /f "tokens=1-4" %%V in ("!ind! !lenR! #!H4! #!L4!") do set "num=!num:~0,%%i!!%%X!!%%Y!!num:~%%V,%%W!"
  625.   )
  626.   call :QRPolynomial.QRPolynomial this num 0
  627.   goto :QRPolynomial.mod.loop
  628. :QRPolynomial.mod.end
  629. (
  630.   endlocal
  631.   set "%~3=%this%"
  632.   exit /b
  633. )
  634. REM end of :QRPolynomial.mod
  635. REM ***
  636. :QRPolynomial.multiply this e multi
  637.   setlocal enabledelayedexpansion
  638.   set "this=!%~1!"
  639.   set "e=!%~2!"
  640.   call :strLen this this.getLength
  641.   call :strLen e e.getLength
  642.   set /a "len = this.getLength + e.getLength - 2, im = this.getLength - 2, jm = e.getLength - 2"
  643.   set "num="
  644.   for /L %%i in (1 1 %len%) do set "num=!num!0"
  645.   for /L %%i in (0 2 %im%) do (
  646.     for /L %%j in (0 2 %jm%) do (
  647.       set /a "a = 0x!this:~%%i,2! << 1, b = 0x!e:~%%j,2! << 1"
  648.       for /f "tokens=1-2" %%a in ("!a! !b!") do (
  649.         set /a "P = 0x!LOG_TABLE:~%%a,2! + 0x!LOG_TABLE:~%%b,2!"
  650.       )
  651.       set /a "t=(P^^P-256)>>IMSB, r=P %% 255, c = ^!r <<IMSB>>IMSB, P = (t & P | ~t & r + ((P>>IMSB ^^ c) & 255)) << 1"
  652.       set /a "lenL = %%i + %%j, ind = lenL + 2, lenR = len - ind"
  653.       for /f "tokens=1-2" %%A in ("!lenL! !P!") do (
  654.         set /a "n = 0x!num:~%%A,2! ^^ 0x!EXP_TABLE:~%%B,2!"
  655.       )
  656.       set /a "H4 = n >> 4, L4 = n & 0xF"
  657.       for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "num=!num:~0,%%U!!%%X!!%%Y!!num:~%%V,%%W!"
  658.     )
  659.   )
  660.   call :QRPolynomial.QRPolynomial T num 0
  661. (
  662.   endlocal
  663.   set "%~3=%T%"
  664.   exit /b
  665. )
  666. REM end of :QRPolynomial.multiply
  667. REM ***
  668. :QRPolynomial.QRPolynomial this.num num shift
  669.   setlocal enabledelayedexpansion
  670.   if "!%~2!"=="" (
  671.     call :throwError "@QRPolynomial.QRPolynomial num:[%~2] / shift=[%~3]"
  672.   )
  673.   set "num=!%~2!"
  674.   set "offset=0"
  675. :QRPolynomial.QRPolynomial.L1
  676.     set /a "offs = offset << 1"
  677.     for %%i in (%offs%) do set "num{offset}=!num:~%%i,2!"
  678.     call :strLen num num.length
  679.     set /a "num.length >>= 1"
  680.     set /a "t = (offset - num.length) & (^! 0x%num{offset}% << IMSB)"
  681.     if %t% lss 0 (
  682.       set /a "offset += 1"
  683.       goto :QRPolynomial.QRPolynomial.L1
  684.     )
  685.   set /a "im = num.length - offset - 1"
  686.   for /L %%i in (0 1 %im%) do (
  687.     set /a "i_offset = %%i + offset << 1"
  688.     for %%a in (!i_offset!) do set "this_num=!this_num!!num:~%%a,2!"
  689.   )
  690.   set /a "shift = %~3"
  691.   for /L %%i in (1 1 %shift%) do (
  692.     set "this_num=!this_num!00"
  693.   )
  694. (
  695.   endlocal
  696.   set "%~1=%this_num%"
  697.   exit /b
  698. )
  699. REM end of :QRPolynomial.QRPolynomial
  700. REM ***
  701. :QRCodeModel.setupTypeNumber modules test typeNumber moduleCount
  702. setlocal enabledelayedexpansion
  703. set "t=!%~1!"
  704. set "t.def=!%~1.defined!"
  705. set /a "typeNumber = %~3"
  706. call :QRUtil.getBCHTypeNumber bits typeNumber
  707. for /L %%i in (0 1 17) do (
  708.   set /a "bit = ^!%~2 & ((bits >> %%i) & 1)"
  709.   set /a "SBB = bit << IMSB >> IMSB, "^
  710.   "ibs = (%%i %% 3 + %~4 - 11) + (%%i / 3) * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  711.   for %%a in (!lenL!) do (
  712.     set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  713.         "quad.def = 0x!t.def:~%%a,1! | bit"
  714.   )
  715.   for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  716.     set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  717.     set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  718.   )
  719. )
  720. for /L %%i in (0 1 17) do (
  721.   set /a "bit = ^!%~2 & ((bits >> %%i) & 1)"
  722.   set /a "SBB = bit << IMSB >> IMSB, "^
  723.   "ibs = (%%i / 3) + (%%i %% 3 + %~4 - 11) * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  724.   for %%a in (!lenL!) do (
  725.     set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  726.         "quad.def = 0x!t.def:~%%a,1! | bit"
  727.   )
  728.   for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  729.     set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  730.     set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  731.   )
  732. )
  733. (
  734.   endlocal
  735.   set "%~1=%t%"
  736.   set "%~1.defined=%t.def%"
  737.   exit /b
  738. )
  739. REM end of :QRCodeModel.setupTypeNumber
  740. REM ***
  741. :QRCodeModel.setupTypeInfo modules test maskPattern errorCorrectLevel moduleCount
  742. setlocal enabledelayedexpansion
  743. set "t=!%~1!"
  744. set "t.def=!%~1.defined!"
  745. set /a "data = %~4 << 3 | %~3"
  746. call :QRUtil.getBCHTypeInfo bits data
  747. for /L %%i in (0 1 14) do (
  748.   if %%i lss 6 (
  749.     set "r=%%i"
  750.   ) else if %%i lss 8 (
  751.     set /a "r = %%i + 1"
  752.   ) else (
  753.     set /a "r = %~5 - 15 + %%i"
  754.   )
  755.   set /a "bit = ^!%~2 & ((bits >> %%i) & 1)"
  756.   set /a "SBB = bit << IMSB >> IMSB, "^
  757.   "ibs = 8 + r * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  758.   for %%a in (!lenL!) do (
  759.     set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  760.         "quad.def = 0x!t.def:~%%a,1! | bit"
  761.   )
  762.   for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  763.     set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  764.     set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  765.   )
  766. )
  767. for /L %%i in (0 1 14) do (
  768.   if %%i lss 8 (
  769.     set /a "c = %~5 - %%i - 1"
  770.   ) else if %%i lss 9 (
  771.     set /a "c = 15 - %%i"
  772.   ) else (
  773.     set /a "c = 14 - %%i"
  774.   )
  775.   set /a "bit = ^!%~2 & ((bits >> %%i) & 1), mod = bit"
  776.   set /a "SBB = bit << IMSB >> IMSB, "^
  777.   "ibs = c + 8 * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  778.   for %%a in (!lenL!) do (
  779.     set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  780.         "quad.def = 0x!t.def:~%%a,1! | bit"
  781.   )
  782.   for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  783.     set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  784.     set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  785.   )
  786. )
  787. set /a "bit = mod"
  788. set /a "SBB = bit << IMSB >> IMSB, "^
  789.   "ibs = 8 + (%~5 - 8) * %~5, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  790. for %%a in (!lenL!) do (
  791.   set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  792.       "quad.def = 0x!t.def:~%%a,1! | bit"
  793. )
  794. for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  795.   set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  796.   set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  797. )
  798. (
  799.   endlocal
  800.   set "%~1=%t%"
  801.   set "%~1.defined=%t.def%"
  802.   exit /b
  803. )
  804. REM end of :QRCodeModel.setupTypeInfo
  805. REM ***
  806. :QRUtil.getBCHTypeInfo BCHTypeInfo data
  807.   setlocal enabledelayedexpansion
  808.   set /a "d = %~2 << 10"
  809. :QRUtil.getBCHTypeInfo.L1
  810.     call :QRUtil.getBCHDigit d.digit d
  811.     set /a "_d = d.digit - G15.DGT"
  812.     if !_d! geq 0 (
  813.       set /a "d ^= G15 << _d"
  814.       goto :QRUtil.getBCHTypeInfo.L1
  815.     )
  816.   set /a "_ = (%~2 << 10 | d) ^ G15_MASK"
  817. (
  818.   endlocal
  819.   set "%~1=%_%"
  820.   exit /b
  821. )
  822. REM end of :QRUtil.getBCHTypeInfo
  823. REM ***
  824. :QRUtil.getBCHTypeNumber BCHTypeNumber data
  825.   setlocal enabledelayedexpansion
  826.   set /a "d = %~2 << 12"
  827. :QRUtil.getBCHTypeNumber.L1
  828.     call :QRUtil.getBCHDigit d.digit d
  829.     set /a "_d = d.digit - G18.DGT"
  830.     if !_d! geq 0 (
  831.       set /a "d ^= G18 << _d"
  832.       goto :QRUtil.getBCHTypeNumber.L1
  833.     )
  834.   set /a "_ = %~2 << 12 | d"
  835. (
  836.   endlocal
  837.   set "%~1=%_%"
  838.   exit /b
  839. )
  840. REM end of :QRUtil.getBCHTypeNumber
  841. REM ***
  842. :QRUtil.getBCHDigit digit data
  843. setlocal enabledelayedexpansion
  844. set /a "t = %~2"
  845. if %t% lss 0 (
  846.   set "_=%WORDSIZE%"
  847. ) else (
  848.   set /a "t <<= 1"
  849.   set "_=0"
  850.   for %%i in (16 8 4 2 1) do (
  851.     set /a "_i = ~-^!(t >> %%i) & %%i, _ |= _i, t >>= _i"
  852.   )
  853. )
  854. (
  855.   endlocal
  856.   set "%~1=%_%"
  857.   exit /b
  858. )
  859. REM end of :QRUtil.getBCHDigit
  860. REM ***
  861. :QRCodeModel.setupPositionAdjustPattern modules typeNumber moduleCount
  862. setlocal enabledelayedexpansion
  863. call :QRUtil.PATTERN_POSITION_TABLE "(%~2 - 1)" pos
  864. call :length pos "_" pos.length
  865. set "t=!%~1!"
  866. set "t.def=!%~1.defined!"
  867. set /a "L_1 = pos.length - 1"
  868. for /L %%i in (0 1 %L_1%) do (
  869.   for /L %%j in (0 1 %L_1%) do (
  870.     call :[] pos %%i row
  871.     call :[] pos %%j col
  872.     set /a "ibs = col + row * %~3, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))"
  873.     for %%a in (!iqs!) do (
  874.       set /a "quad.def = 0x!t.def:~%%a,1! & bit"
  875.     )
  876.     if !quad.def!==0 (
  877.       for /L %%r in (-2 1 2) do (
  878.         for /L %%c in (-2 1 2) do (
  879.           set /a "bit = ^!(%%r & 3 ^^ 2) | ^!(%%c & 3 ^^ 2) | ^!(%%r | %%c), SBB = bit << IMSB >> IMSB"
  880.           set /a "ibs = col + %%c + (row + %%r) * %~3, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  881.           for %%a in (!lenL!) do (
  882.             set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  883.                 "quad.def = 0x!t.def:~%%a,1! | bit"
  884.           )
  885.           for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  886.             set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  887.             set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  888.           )
  889.         )
  890.       )
  891.     )
  892.   )
  893. )
  894. (
  895.   endlocal
  896.   set "%~1=%t%"
  897.   set "%~1.defined=%t.def%"
  898.   exit /b
  899. )
  900. REM end of :QRCodeModel.setupPositionAdjustPattern
  901. REM ***
  902. :{} list index vRet
  903. setlocal enabledelayedexpansion
  904. set "T=!%~1!"
  905. set /a "i = %~2"
  906. if %i% leq 0 (
  907.   for /f %%a in ("%T%") do set "_=%%a"
  908.   goto :{}.End
  909. )
  910.   set /a "i1 = i + 1"
  911. :{}.Loop1
  912.       if %i1% gtr 31 (
  913.         for /f "tokens=31*" %%a in ("%T%") do set "T=%%b"
  914.         set /a "i1 -= 31"
  915.         goto :{}.Loop1
  916.       )
  917.       for /f "tokens=%i1%" %%a in ("%T%") do set "_=%%a"
  918. :{}.End
  919. (
  920.   endlocal
  921.   set "%~3=%_%"
  922.   exit /b
  923. )
  924. REM end of :{}
  925. REM ***
  926. :[] array index vrt
  927. setlocal enabledelayedexpansion
  928. set "_="
  929. set /a "t=%~2 + 1"
  930. if "!%~1!" neq "." (
  931.   for /f "tokens=%t% delims=_" %%a in ("!%~1!") do set "_=%%a"
  932. )
  933. (
  934.   endlocal
  935.   set "%~3=%_%"
  936.   exit /b
  937. )
  938. REM end of :[]
  939. REM ***
  940. :length list delim len
  941. setlocal enabledelayedexpansion
  942. if "!%~1!"=="." (
  943.   set "_=0"
  944. ) else (
  945.   set /a "_=1+(!%~1:%~2=&0)+1+(0&!)"
  946. )
  947. (
  948.   endlocal
  949.   set "%~3=%_%"
  950.   exit /b
  951. )
  952. REM end of :length
  953. REM ***
  954. :QRUtil.PATTERN_POSITION_TABLE index arrRt
  955. setlocal enabledelayedexpansion
  956. set /a "t=%~1, p=t-31"
  957. if %t% leq 0 (
  958.   set "_=."
  959. ) else if %p% leq 0 (
  960.   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 (
  961.     set "_=%%a"
  962.   )
  963. ) else (
  964.   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 (
  965.     set "_=%%a"
  966.   )
  967. )
  968. (
  969.   endlocal
  970.   set "%~2=%_%"
  971.   exit /b
  972. )
  973. REM end of :QRUtil.PATTERN_POSITION_TABLE
  974. REM ***
  975. :QRUtil.getLengthInBits mode type len
  976. setlocal enabledelayedexpansion
  977. set /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,"^
  978.     "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"
  979. if %_t%==0 (
  980.   call :throwError "ERROR type: %t%"
  981. ) else (
  982.   set "_=!@%_t%%_m%!"
  983. )
  984. (
  985.   endlocal
  986.   set "%~3=%_%"
  987.   exit /b
  988. )
  989. REM end of :QRUtil.getLengthInBits
  990. REM ***
  991. :throwError errInfo
  992.   color CF
  993.   echo; & echo; & echo;ERROR & echo; & echo; %~1
  994.   <nul set /p "=Any key to exit..."
  995.   >nul pause
  996.   EXIT
  997. exit /b
  998. REM ***
  999. :QRCodeModel.setupTimingPattern modules moduleCount
  1000.   setlocal enabledelayedexpansion
  1001.   set "t=!%~1!"
  1002.   set "t.def=!%~1.defined!"
  1003.   set /a "_m = %~2 - 9"
  1004.   for /L %%r in (8 1 %_m%) do (
  1005.     set /a "ibs = 6 + %%r * %~2, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))"
  1006.     for %%a in (!iqs!) do (
  1007.       set /a "quad.def = 0x!t.def:~%%a,1! & bit"
  1008.     )
  1009.     if !quad.def!==0 (
  1010.       set /a "bit = ~%%r & 1"
  1011.       set /a "SBB = bit << IMSB >> IMSB, "^
  1012.       "ibs = 6 + %%r * %~2, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  1013.       for %%a in (!lenL!) do (
  1014.         set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  1015.             "quad.def = 0x!t.def:~%%a,1! | bit"
  1016.       )
  1017.       for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  1018.         set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  1019.         set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  1020.       )
  1021.     )
  1022.   )
  1023.   for /L %%c in (8 1 %_m%) do (
  1024.     set /a "ibs = %%c + 6 * %~2, iqs = ibs >> 2, bit = 1 << (3 ^ (ibs & 3))"
  1025.     for %%a in (!iqs!) do (
  1026.       set /a "quad.def = 0x!t.def:~%%a,1! & bit"
  1027.     )
  1028.     if !quad.def!==0 (
  1029.       set /a "bit = ~%%c & 1"
  1030.       set /a "SBB = bit << IMSB >> IMSB, "^
  1031.       "ibs = %%c + 6 * %~2, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^ (ibs & 3))"
  1032.       for %%a in (!lenL!) do (
  1033.         set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  1034.             "quad.def = 0x!t.def:~%%a,1! | bit"
  1035.       )
  1036.       for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  1037.         set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  1038.         set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  1039.       )
  1040.     )
  1041.   )
  1042. (
  1043.   endlocal
  1044.   set "%~1=%t%"
  1045.   set "%~1.defined=%t.def%"
  1046.   exit /b
  1047. )
  1048. REM end of :QRCodeModel.setupTimingPattern
  1049. REM ***
  1050. :QRCodeModel.setupPositionProbePattern modules row col moduleCount
  1051.   setlocal enabledelayedexpansion
  1052.   set "t=!%~1!"
  1053.   set "t.def=!%~1.defined!"
  1054.   set "lss=-"  &  set "LEQ=-1-"
  1055.   for /L %%r in (-1 1 7) do (
  1056.     set /a "_r = %~2 + %%r, SBB = _r %LEQ% -1 | %~4 %LEQ% _r"
  1057.     if !SBB! geq 0 (
  1058.       for /L %%c in (-1 1 7) do (
  1059.         set /a "_c = %~3 + %%c, SBB = _c %LEQ% -1 | %~4 %LEQ% _c"
  1060.         if !SBB! geq 0 (
  1061.           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, "^
  1062.           "ibs = _c + _r * %~4, lenL = ibs >> 2, ind = lenL + 1, lenR = iQuadMax - ind, bit = 1 << (3 ^^ (ibs & 3))"
  1063.           for %%a in (!lenL!) do (
  1064.             set /a "quad = 0x!t:~%%a,1!, quad = SBB & (bit | quad) | ~SBB & (~bit & quad), "^
  1065.                 "quad.def = 0x!t.def:~%%a,1! | bit"
  1066.           )
  1067.           for /f "tokens=1-5" %%A in ("!lenL! !ind! !lenR! #!quad! #!quad.def!") do (
  1068.             set "t=!t:~0,%%A!!%%D!!t:~%%B,%%C!"
  1069.             set "t.def=!t.def:~0,%%A!!%%E!!t.def:~%%B,%%C!"
  1070.           )
  1071.         )
  1072.       )
  1073.     )
  1074.   )
  1075. (
  1076.   endlocal
  1077.   set "%~1=%t%"
  1078.   set "%~1.defined=%t.def%"
  1079.   exit /b
  1080. )
  1081. REM end of :QRCodeModel.setupPositionProbePattern
  1082. REM ***
  1083. :paint modules moduleCount test
  1084.   setlocal enabledelayedexpansion
  1085.   if "%~3" neq "" (set /a "test = %~3") else set "test=0"
  1086.   echo;
  1087.   color 0F & echo;
  1088.   set "BLACK= " & set "WHITE=%ASCII219%"
  1089.   for %%i in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do (
  1090.     set "bits="
  1091.     for /L %%j in (3 -1 0) do (
  1092.       set /a "b = 0x%%i >> %%j & 1"
  1093.       set "bits=!bits!!b!"
  1094.     )
  1095.     set "bits=!bits:0=%WHITE%!"
  1096.     set "H2B=!H2B!"%%i=!bits:1=%BLACK%!" "
  1097.   )
  1098.   echo;
  1099.   set "w_quietZone=1"
  1100.   set /a "w = %~2 - 1, w1 = w_quietZone * 2 + %~2"
  1101.   set "quietZone=" & for /L %%i in (1 1 !w_quietZone!) do set "quietZone=!quietZone!%WHITE%"
  1102.   for /L %%i in (1 1 !w_quietZone!) do (for /L %%j in (1 1 !w1!) do <nul set /p "=%WHITE%") & echo;
  1103.   for /L %%i in (0 1 !w!) do (
  1104.     set /a "ibs = %~2 * %%i, iqs = ibs >> 2, quadLen = ((ibs + %~2 - 1) >> 2) - iqs + 1, ibs &= 3"
  1105.     for /f "tokens=1-2" %%s in ("!iqs! !quadLen!") do (
  1106.       set "_t=!%~1:~%%s,%%t!"
  1107.       if %test%==1 set "t.defined=!%~1.defined:~%%s,%%t!"
  1108.     )
  1109.     for %%a in (%H2B%) do (
  1110.       set "_t=!_t:%%~a!"
  1111.       if %test%==1 set "t.defined=!t.defined:%%~a!"
  1112.     )
  1113.     if %test%==1 (
  1114.       set /a "im = (quadLen << 2) - 1"
  1115.       set "t="
  1116.       for /L %%i in (0 1 !im!) do (
  1117.         if "!t.defined:~%%i,1!"=="%BLACK%" (
  1118.           set "t=!t!!_t:~%%i,1!"
  1119.         ) else (
  1120.           set "t=!t!*"
  1121.         )
  1122.       )
  1123.     ) else (
  1124.       set "t=!_t!"
  1125.     )
  1126.     for /f "tokens=1-2" %%s in ("!ibs! !%~2!") do echo;!quietZone!!t:~%%s,%%t!!quietZone!
  1127.   )
  1128.   for /L %%i in (1 1 !w_quietZone!) do (for /L %%j in (1 1 !w1!) do <nul set /p "=%WHITE%") & echo;
  1129.   endlocal
  1130.   exit /b
  1131. REM end of :paint
  1132. REM ***
  1133. :QRBitBuffer.put QRBitBuffer.buffer QRBitBuffer.length num length
  1134. setlocal enabledelayedexpansion
  1135. set "_b=!%~1!"
  1136. set "_L=!%~2!"
  1137. set /a "im = %~4 - 1"
  1138. for /L %%i in (0 1 %im%) do (
  1139.   call :QRBitBuffer.putBit _b _L "((%~3 >> (im - %%i)) & 1)"
  1140. )
  1141. (
  1142.   endlocal
  1143.   set "%~1=%_b%"
  1144.   set "%~2=%_L%"
  1145.   exit /b
  1146. )
  1147. REM end of :QRBitBuffer.put
  1148. REM ***
  1149. :QRBitBuffer.putBit QRBitBuffer.buffer QRBitBuffer.length bit
  1150.   setlocal enabledelayedexpansion
  1151.   set "_b=!%~1!"
  1152.   call :strLen _b _buf_len
  1153.   set /a "_buf_len >>= 1"
  1154.   set /a "_L = %~2, bufIndex = _L >> 3, bit = %~3"
  1155.   if %_buf_len% leq %bufIndex% (
  1156.     set "_b=%_b%00"
  1157.   )
  1158.   if %bit%==1 (
  1159.     set /a "lenL = bufIndex << 1, ind = lenL + 2, lenR = (_buf_len << 1) - ind"
  1160.     for %%i in (!lenL!) do set /a "_byte = (0x!_b:~%%i,2!) | (0x80 >> (_L & 7))"
  1161.     set /a "H4 = _byte >> 4, L4 = _byte & 0xF"
  1162.     for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "_b=!_b:~0,%%U!!%%X!!%%Y!!_b:~%%V,%%W!"
  1163.   )
  1164.   set /a "_L += 1"
  1165. (
  1166.   endlocal
  1167.   set "%~1=%_b%"
  1168.   set "%~2=%_L%"
  1169.   exit /b
  1170. )
  1171. REM end of :QRBitBuffer.putBit
  1172. REM ***
  1173. :QRCodeModel.addData QRCodeModel.dataList QRCodeModel.dataCache data
  1174. setlocal enabledelayedexpansion
  1175. set "dataList=!%~1!"
  1176. set "data=!%~3!"
  1177. call :QR8bitByte.parsedData data parsedData
  1178. if "%dataList%"=="" (
  1179. set "dataList=!parsedData!"
  1180. ) else (
  1181. set "dataList=%dataList% !parsedData!"
  1182. )
  1183. (
  1184.   endlocal
  1185.   set "%~1=%dataList%"
  1186.   set "%~2="
  1187.   exit /b
  1188. )
  1189. REM end of :QRCodeModel.addData
  1190. REM ***
  1191. :QR8bitByte.parsedData str parsedData
  1192. (
  1193.   setlocal enabledelayedexpansion
  1194.   set "ASCII_20_7E=01234567890123456789012345678901 ^!"#$%%^&'(^)*+,-./0123456789:;^<=^>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^^^_`abcdefghijklmnopqrstuvwxyz{^|}~"
  1195.   for /L %%i in (0x20 1 0x7e) do (
  1196.     set /a "H4 = %%i >> 4, L4 = %%i & 0xF"
  1197.     for /f "tokens=1-2" %%U in ("#!H4! #!L4!") do set "hex=!%%U!!%%V!"
  1198.     if "!ASCII_20_7E:~%%i,1!"=="^" (
  1199.       set "_^=5E"
  1200.     ) else if "!ASCII_20_7E:~%%i,1!"=="*" (
  1201.       REM set _*=!hex!
  1202.     ) else (
  1203.       for %%a in ("!ASCII_20_7E:~%%i,1!") do (
  1204.         if "%%~a" lss "a" (
  1205.           if "%%~a"=="!" (
  1206.             set "_^!=21"
  1207.           ) else (
  1208.             set _%%~a=!hex!
  1209.           )
  1210.         ) else if "%%~a" leq "Z" (
  1211.           for /f "delims=ABCDEFGHIJKLMNOPQRSTUVWXYZ" %%b in ("%%~a") do set #%%~a=!hex!
  1212.           for /f "delims=abcdefghijklmnopqrstuvwxyz" %%b in ("%%~a") do set _%%~a=!hex!
  1213.         ) else (
  1214.           set _%%~a=!hex!
  1215.         )
  1216.       )
  1217.     )
  1218.   )
  1219.   REM set "_*=42" & set "_?=63" &   rem * and ? are wildcard, the above code does not generate
  1220.                                     rem the corresponding variables, but also unnecessary
  1221.   set "t="
  1222.   call :strLen "%~1" iEnd
  1223.   set /a "iEnd -= 1, next = 0"
  1224.   for /L %%i in (0 1 !iEnd!) do (
  1225.     if %%i geq !next! (
  1226.       set "isEscape=0"
  1227.       if /i "!%~1:~%%i,2!"=="\x" (
  1228.         set /a "isEscape = 1, A = %%i + 2, B = A + 1"
  1229.         for %%n in (!A! !B!) do (
  1230.             if "!%~1:~%%n,1!"=="" (
  1231.                 set "isEscape=0"
  1232.             ) else if "!%~1:~%%n,1!"==";" (
  1233.                 set "isEscape=0"
  1234.             ) else (
  1235.                 for /f "delims=0123456789abcdefABCDEF" %%b in ("!%~1:~%%n,1!") do (
  1236.                     set "isEscape=0"
  1237.                 )
  1238.             )
  1239.         )
  1240.         if !isEscape! equ 1 (
  1241.             for %%n in (!A!) do (
  1242.                 set "t=!t!!%~1:~%%n,2!"
  1243.                 set /a "next = %%i + 4"
  1244.             )
  1245.         )
  1246.       )
  1247.       if !isEscape! equ 0 (
  1248.         for /f delims^=^ eol^= %%j in ("!%~1:~%%i,1!") do (
  1249.           if        "%%j"=="!" (
  1250.                                     set "t=!t!21"
  1251.           ) else if "%%j"=="*" (
  1252.                                     set "t=!t!2A"
  1253.           ) else if "%%j"=="?" (
  1254.                                     set "t=!t!3F"
  1255.           ) else (
  1256.             if "%%j"=="=" (
  1257.                                     set "t=!t!3D"
  1258.             ) else if "%%j" lss "a" (
  1259.               set "t=!t!!_%%j!"
  1260.             ) else if "%%j" leq "Z" (
  1261.               for /f "delims=ABCDEFGHIJKLMNOPQRSTUVWXYZ" %%b in ("%%j") do set "t=!t!!#%%j!"
  1262.               for /f "delims=abcdefghijklmnopqrstuvwxyz" %%b in ("%%j") do set "t=!t!!_%%j!"
  1263.             ) else (
  1264.               set "t=!t!!_%%j!"
  1265.             )
  1266.           )
  1267.         )
  1268.       )
  1269.     )
  1270.   )
  1271. )
  1272. (
  1273.   endlocal
  1274.   set "%~2=%t%"
  1275.   exit /b
  1276. )
  1277. REM end of :QR8bitByte.parsedData
  1278. REM ***
  1279. :strLen str len
  1280. (
  1281.   setlocal enabledelayedexpansion
  1282.   set "len=0" & set "T=!%~1!#"
  1283.   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!"
  1284. )
  1285. (
  1286.   endlocal
  1287.   set "%~2=%len%"
  1288.   exit /b
  1289. )
  1290. REM end of :strLen
  1291. REM ***
  1292. :QRMath.glog n vRet
  1293.   setlocal enabledelayedexpansion
  1294.   set /a "n = %~1, i = n << 1"
  1295.   if %n% lss 1 (
  1296.     call :throwError "@QRMath.glog n:[%~1]"
  1297.   )
  1298.   for %%i in (%i%) do set "ret=!LOG_TABLE:~%%i,2!"
  1299. (
  1300.   endlocal
  1301.   set "%~2=%ret%"
  1302.   exit /b
  1303. )
  1304. REM end of :QRMath.glog
  1305. REM ***
  1306. :QRMath.gexp n vRet
  1307.   setlocal enabledelayedexpansion
  1308.   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"
  1309.   for %%i in (%i%) do set "ret=!EXP_TABLE:~%%i,2!"
  1310. (
  1311.   endlocal
  1312.   set "%~2=%ret%"
  1313.   exit /b
  1314. )
  1315. REM end of :QRMath.gexp
  1316. REM ***
  1317. :init.LOG_TABLE LOG_TABLE
  1318.   setlocal enabledelayedexpansion
  1319.   set "T="
  1320.   for /L %%i in (0 1 255) do set "T=!T!.."
  1321.   call :strlen T LOG_TABLE_LEN
  1322.   for /L %%i in (0 1 254) do (
  1323.     set /a "_i = %%i << 1, H4 = %%i >> 4, L4 = %%i & 0xF"
  1324.     for %%a in (!_i!) do set /a "lenL = 0x!EXP_TABLE:~%%a,2! << 1"
  1325.     set /a "ind = lenL + 2, lenR = LOG_TABLE_LEN - ind"
  1326.     for /f "tokens=1-5" %%U in ("!lenL! !ind! !lenR! #!H4! #!L4!") do set "T=!T:~0,%%U!!%%X!!%%Y!!T:~%%V,%%W!"
  1327.   )
  1328. (
  1329.   endlocal
  1330.   set "%~1=%T%"
  1331.   exit /b
  1332. )
  1333. REM end of :init.LOG_TABLE
  1334. REM ***
  1335. :init.EXP_TABLE EXP_TABLE
  1336.   setlocal enabledelayedexpansion
  1337.   set "ET="
  1338.   for /L %%i in (0 1 7) do (
  1339.     set /a "t = 1 << %%i, H4 = t >> 4, L4 = t & 0xF"
  1340.     for /f "tokens=1-2" %%X in ("#!H4! #!L4!") do (
  1341.       set "ET=!ET!!%%X!!%%Y!"
  1342.     )
  1343.   )
  1344.   for /L %%i in (8 1 255) do (
  1345.     set /a "i_4 = %%i - 4 << 1, i_5 = %%i - 5 << 1, i_6 = %%i - 6 << 1, i_8 = %%i - 8 << 1"
  1346.     for /f "tokens=1-4" %%a in ("!i_4! !i_5! !i_6! !i_8!") do (
  1347.       set /a "t = 0x!ET:~%%a,2! ^^ 0x!ET:~%%b,2! ^^ 0x!ET:~%%c,2! ^^ 0x!ET:~%%d,2!"
  1348.       set /a "H4 = t >> 4, L4 = t & 0xF"
  1349.       for /f "tokens=1-2" %%X in ("#!H4! #!L4!") do set "ET=!ET!!%%X!!%%Y!"
  1350.     )
  1351.   )
  1352. (
  1353.   endlocal
  1354.   set "%~1=%ET%"
  1355.   exit /b
  1356. )
  1357. REM end of :init.EXP_TABLE
  1358. REM ***
  1359. :autoResizeScr typeNumber margin
  1360. setlocal
  1361. for /f "tokens=1-2 delims=:" %%a in ('mode ^| find /i "s:" ^| find /i "n"') do set /a "%%a=%%b"
  1362. set /a "moduleCount = %~1 * 4 + 17"
  1363. set /a "sizeMin = moduleCount + %~2"
  1364. set /a "resize = Lines - sizeMin | Columns - sizeMin"
  1365. set /a "Lines = (t = Lines - sizeMin >> IMSB, t & sizeMin | ~t & Lines)"
  1366. set /a "Columns = (t = Columns - sizeMin >> IMSB, t & sizeMin | ~t & Columns)"
  1367. if %resize% lss 0 mode %Columns%, %Lines%
  1368. endlocal
  1369. exit /b
  1370. REM end of :autoResizeScr
  1371. REM ***
  1372. :clearVars
  1373. set "Path=%SystemRoot%\system32"
  1374. for /f "delims==" %%a in ('set') do (
  1375.   if /i "%%a" neq "Path" set "%%a="
  1376. )
  1377. exit /b
  1378. REM end of :clearVars
  1379. REM ***
  1380. :getBackSpaceAndASCII219
  1381. call :getASCII219
  1382. >nul copy 219.chr /b + 13.chr /b 219_CR.chr /b
  1383. <219_CR.chr set /p "ASCII219="
  1384. for %%N in (13 219 219_CR) do del %%N.chr
  1385. call :getBackSpace BS
  1386. exit /b
  1387. REM end of :getBackSpaceAndASCII219
  1388. REM ***
  1389. :getASCII219
  1390. setlocal
  1391. set ^"genchr=(^
  1392.   for %%N in (13 219) do if not exist %%N.chr (^
  1393.   makecab /d compress=off /d reserveperdatablocksize=26 /d reserveperfoldersize=%%N 0.tmp %%N.chr ^>nul^&^
  1394.   type %%N.chr ^| ((for /l %%n in (1 1 38) do pause)^>nul^&findstr "^^" ^>%%N.temp)^&^
  1395.   ^>nul copy /y %%N.temp /a %%N.chr /b^&^
  1396.   del %%N.temp^
  1397.   )^
  1398. )^&^
  1399. del 0.tmp^"
  1400. for %%N in (13 219) do (del /f /q /a %%N.chr >nul 2>&1)
  1401. type nul >0.tmp
  1402. cmd /q /v:on /c "%genchr%"
  1403. endlocal
  1404. exit /b
  1405. REM end of :getASCII219
  1406. REM ***
  1407. :getBackSpace vRet
  1408. for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "%~1=%%a"
  1409. exit /b
  1410. REM end of :getBackSpace
  1411. REM ***
  1412. :quickShow
  1413. setlocal
  1414. set "modules=FE44313AFBEA776CB43FC13E02CA360F524F2DD06E9322A555E5CE966FABB75A517E1715F2C11455DBAFFCAFF0EF0F878202EC13D33C414E1C672B2907FAAAAAAAAAAAAAAAAAFE0016CF14C94D13137500C7033FFF6840F897070C4AFAD29F33B324C2CD720CF14BED1585F5A250D740B3511151B0347AFE2E3766265B0A0DB73511A388221747342F4714195737584599A05A25595D295C80A8A7B45218D6E66DBEC36FB71F581718448E0C5A08A2DBEEB431751102E4886420DC5D2E6A4F2D2BA29ACD92E974F2B616CF2C7FF587F11ACC3296904AA42CE7BE107DD8C6508FF4B56DDCB643B90F2CBB87341D09514F9900660FAC6DFED9FCFF398BF8A44010C74EFAC54D29C7FAB2892A083FAB1DDCABC91C11F15E4D7142DA51F3F918FFD9D3BFF6301F852752BE76C760DC98C35549361A710C1260A0C0081BE4EDC20990F7237BBEA7ACBE31385162DB8D84F413A667BFFB315749B8B1F4BA8370F6A94A56815E2110CDFF93DB7E53992C6E54342D9FC0F9DB1487E5A6565BEFB5960896F6BD10B0853B57D1BD280DCA2CFECD5CD482ED67CF5E928D9B382490CE27B0C833E267247418C51826E8B17AA3FF7D640C69E73B3214917C84513AB7B0CE2561C173EE71289A42140369271B31F4C581D800EC0D6019DBC1CAFD6C44E2B1B8E40055EB12EB967FDBAFF8FADAF975A8FD1C7800C70AF2C418A54602B5AD6A0B40AB3FD8AA571B0811B8AFD1925AD1C3FEDE7FC6B20FACB8AFC826487C7A73A4009CD7B06DD9F6F63E732648A6566A918E4CC953435B73BDF325BECF3C37BC9FEF9820FC56DB7737759618C611AD879402D1830DB031051F423EB19D3C721B02F96FA65FCA1EB7DFD15A25AC9A463C07C45D5048879FFA6A064F00D575082C195BE3DC86D746B76CED6B748CE6086536CAE8D9B6C076B3ACF0A19CDCBBD6C8DDEFDB3B787E72F4BB8F484C94A92DF233A348FACBFD16F121C452CC8D663269EFBEFB78000EE1C9084D2DFCD820BF49B48B3A5BE10AD3C571387473D9CFFFECBEFBB54DFC805D01450672458131C53FA841AA4830ABDB546B105B19D194659146F7F1CBA2E0EFFBC3EFB6FA8F8DD108A0D6016D1D454AB2E8F29A910A060263412F05EBAF920F143B12B124FEE936636A62FCFFA49100"
  1415. set /a "moduleCount = 17 + 4 * 16"
  1416. call :paint modules moduleCount
  1417. endlocal
  1418. exit /b
  1419. REM end of :quickShow
  1420. REM ***
  1421. :delReg
  1422. setlocal enabledelayedexpansion
  1423. set "s=!time:~-4,1!"
  1424. :delReg.loop
  1425. set /a "elapse = (1!time:~-4,1! - s) %% 10"
  1426. if %elapse% lss 2 goto :delReg.loop
  1427. >nul reg delete HKCU\Console\QRCODE_CMD /f
  1428. endlocal
  1429. exit /b
  1430. REM end of :delReg
  1431. REM ***
  1432. :initGlobalVars
  1433. for /l %%i in (7 8 127) do set /a "_=1<<%%i>>%%i>>1, IMSB=_&%%i|~_&IMSB"
  1434. set /a "WORDSIZE = IMSB + 1"
  1435. set /a "MODE_NUMBER = 1 << 0, MODE_ALPHA_NUM = 1 << 1, MODE_8BIT_BYTE = 1 << 2, MODE_KANJI = 1 << 3"
  1436. set /a "G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0)"
  1437. set /a "G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0)"
  1438. set /a "G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1)"
  1439. call :QRUtil.getBCHDigit G18.DGT G18
  1440. call :QRUtil.getBCHDigit G15.DGT G15
  1441. call :getBackSpaceAndASCII219
  1442. for %%i in (0 1 2 3 4 5 6 7 8 9 A B C D E F) do (
  1443.   set /a "i = 0x%%i"
  1444.   set "#!i!=%%i"
  1445. )
  1446. call :init.EXP_TABLE EXP_TABLE
  1447. call :init.LOG_TABLE LOG_TABLE
  1448. exit /b
  1449. REM end of :initGlobalVars
  1450. REM ***
  1451. :initCON
  1452. @echo off
  1453. for %%a in (  FontSize:00080008      FontFamily:00000030  WindowSize:00C800C8
  1454.               ScreenColors:0000000f  CodePage:000001b5    ScreenBufferSize:00C800C8
  1455. ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
  1456.   >nul reg add HKCU\Console\QRCODE_CMD /v %%b /t reg_dword /d 0x%%c /f
  1457. )
  1458. start "QRCODE_CMD" /max "%ComSpec%" /c "%~0" REM & (call :delReg) & exit
  1459. REM end of :initCON
复制代码

作者: amwfjhh    时间: 2014-11-13 09:34

强贴……这个没专业知识搞不下来了。只有带着崇敬之心收藏用之……
作者: 523066680    时间: 2014-11-13 22:55

这个不错,以后传送链接或者文字信息到手机里面方便多了

主题类型属于 实际应用
作者: neorobin    时间: 2014-11-13 23:06

回复 3# 523066680

由于运行速度的原因, 这个真不好意思放进实际应用类
作者: 523066680    时间: 2014-11-13 23:12

本帖最后由 523066680 于 2014-11-13 23:21 编辑

回复 4# neorobin


      突然想起来,也许可以生成 .svg文件,这样就是矢量图了。
不过svg的脚本描述方式要花点时间学习。

看这里
http://www.w3school.com.cn/svg/svg_rect.asp

svg矢量图 一般用浏览器能浏览到,编辑的话是coreldraw 或者 gimp/inkscape
作者: neorobin    时间: 2014-11-13 23:18

回复 5# 523066680

除了生成图形文件外, 还有一个难点 就是 直接支持 Unicode,

即使这两点都实现了, 速度还被放在了一边, 哈哈.
作者: neorobin    时间: 2014-11-13 23:21

回复 5# 523066680

针对于 QR Code, 感觉只要学会用 矩形 <rect> 好象就足够了
作者: 523066680    时间: 2014-11-13 23:22

回复 7# neorobin


    恩,早点休息。年轻不养生,老了养医生
作者: amwfjhh    时间: 2014-11-14 17:25

回复  neorobin


    恩,早点休息。年轻不养生,老了养医生
523066680 发表于 2014-11-13 23:22



呃,好经典的话……
作者: ads350668398    时间: 2014-11-14 18:33

Input data:1
Choose a error correct level (L/M/Q/H):1
Choose a mask pattern between 0 and 7 :1

QRCode.makeCode

data=1
errorCorrectLevel=1
maskPattern=1
TypeNumber=1
oQRCodeModel.dataList=31
QRCodeModel.setupPositionProbePattern
QRCodeModel.setupPositionAdjustPattern
QRCodeModel.setupTimingPattern
QRCodeModel.setupTypeInfo
COLUMN: -1/20


███████████████████████
█       █ ███ █       █
█ █████ █ █ ███ █████ █
█ █   █ █████ █ █   █ █
█ █   █ ███████ █   █ █
█ █   █ █     █ █   █ █
█ █████ █  █  █ █████ █
█       █ █ █ █       █
█████████ ███ █████████
█   ██  █ █ ██    ██  █
█     ███ █  █   █  ███
█ █ ███ ███    █   █  █
█ ██   ██ ██ █   █   ██
██  ██  ████          █
█████████  █████████  █
█       ███ ███ ███   █
█ █████ █ ███ ███ ██ ██
█ █   █ ███ ███ ███   █
█ █   █ ██ █ █   █  ███
█ █   █ █ █    █   █  █
█ █████ █    █   █  ███
█       █           █ █
███████████████████████

Input data:
Choose a error correct level (L/M/Q/H):2
Choose a mask pattern between 0 and 7 :2

QRCode.makeCode

data=1
errorCorrectLevel=1
maskPattern=2
TypeNumber=1
oQRCodeModel.dataList=31
QRCodeModel.setupPositionProbePattern
QRCodeModel.setupPositionAdjustPattern
QRCodeModel.setupTimingPattern
QRCodeModel.setupTypeInfo
COLUMN: -1/20


███████████████████████
█       ███   █       █
█ █████ █   █ █ █████ █
█ █   █ ███   █ █   █ █
█ █   █ █  ██ █ █   █ █
█ █   █ ██ ██ █ █   █ █
█ █████ █ ██ ██ █████ █
█       █ █ █ █       █
██████████ ████████████
█     █   ██ █ █ █ █ ██
██  █ ███       ██ ████
█  ██     ███ █  ██████
█████  ██  █    ██ █ ██
█████ █   █ █ ██ ██ ███
█████████ ███ ██ ██   █
█       █ ██ █ ██   ███
█ █████ ██ █████  █  ██
█ █   █ █ ██ █ ██   ███
█ █   █ █ ██    ██ ████
█ █   █ █ ███ █  ██████
█ █████ █ █     ██ ████
█       █  ██ ██ ██  ██
███████████████████████

Input data:
作者: neorobin    时间: 2014-11-15 12:58

版本20141113, 当数据中含有双引号时, 有可能导致程序退出.

此问题已更正, 顶楼代码已更新
作者: cjiabing    时间: 2014-11-15 22:20

复制生成的“二维码”到记事本,使用两个空格替换一个空格,即可在记事本上获得完整的二维码图形!!!~——可惜扫描不了!~黑白色互换了!~!
将生成的“二维码”抓图,使用画图工具重新调整大小,取消保持纵横比例,宽使用85,长使用50调整,就可以生成标准的二维码图标了,并且还可以扫一扫哦!~!~
作者: cjiabing    时间: 2014-11-15 22:34

回复 12# cjiabing


    仔细观察了下,可以直接在TXT上生成手机可以“扫一扫”的真正二维码!~
第一步:将生成的“二维码”复制到记事本;
第二步:将“白色空格”全部替换成“黑”字;
第三步:将“黑色方块”全部替换成空格——一个黑色方块等于两个空格!
第四步:将“黑”替换成“黑色方块”。
一个标准的二维码图标是不是出来了?!~
原因是前面黑白颠倒了,调整过来之后,拿出你的手机来试一试吧!~
楼主修正下吧,直接在TXT上生成!~
作者: neorobin    时间: 2014-11-16 10:26

回复 13# cjiabing

将第 2 行的 REM 去掉, 即可通过写注册表的方式把控制台字体尺寸设置为 8X8 像素, 二维码图形就成为正方形了.

QR code 标准中要求单元模块及整个二维码图形是正方形, 实际扫描时, 由于印刷表面不平整, 以及扫描镜头轴线不与图形中心垂线相重合, 都会造成不同程度的形变失真.

但对于优秀的解码器而言, 这些失真在较大程度上都是可以克服的, 甚至原始图形是长和宽相差较大的矩形, 也能正确解码.
所知比较优秀的解码器有 Qrafter Pro, RedLaser, 以及 ZXing 项目.

"A dark module is a binary one and a light module is a binary zero."

标准中要求二进制位值为 1 的模块为深色, 为 0 的模块为浅色, 而不是必须为黑白两种颜色.
  1.   color 0F & echo;
  2.   set "BLACK= " & set "WHITE=%ASCII219%"
复制代码
以上是 paint 过程中的两行代码, 修改 color 语句 或者 把 BLACK 和 WHITE 两个变量的值互换都可以实现图形反相, 如果这两个同时都修改了, 就成了二次反相, 就还原了.

在记事本中, 最快速的反相就是把文本全选.
作者: cjiabing    时间: 2014-11-16 20:05

回复 14# neorobin


    原来早有机关在里面!~原理和代码太专业了,看不懂!~
只想用来玩玩,输入几个字符,你给我搞一个二维码出来直接用手机扫一扫就可以了,其他多余的东西就不想看了!~
哈哈哈!~谢谢分享!~
作者: qzwqzw    时间: 2014-11-28 16:28

拜读了大作
看来是多年来心血的结晶
仅提供几点建议

一是可以支持从文件中读取字符串
这样可以处理多行文本

二是使用独立cmd窗口显示QRCode
这样可以灵活控制QRCode的显示样式

三是处理UTF8编码的编码
可以考虑使用debug -d转换为hex text

另外最后一个小建议
把变量BLACK与WHITE改个名字
比如BIT0与BIT1之类
避免阅读上的麻烦

本来想自己改改
后来想想调试太累
只有放弃
作者: MCRGZN    时间: 2015-8-13 23:08

不错不错不错不错不错
作者: 老刘1号    时间: 2017-4-23 13:54

本帖最后由 老刘1号 于 2017-4-23 14:12 编辑

回复 16# qzwqzw


    可以支持汉字了,自动转UTF-8
作者: Echo11    时间: 2022-9-30 13:40

2022年到此一游。
一、win11
  1. Input data:http://www.bathome.net/
  2. Choose a error correct level (L/M/Q/H):H
  3. Choose a mask pattern between 0 and 7 :7
  4. QRCode.makeCode
  5. data=http://www.bathome.net/
  6. errorCorrectLevel=2
  7. maskPattern=7
  8. TypeNumber=3
  9. oQRCodeModel.dataList=687474703A2F2F7777772E626174686F6D652E6E65742F
  10. QRCodeModel.setupPositionProbePattern
  11. QRCodeModel.setupPositionAdjustPattern
  12. QRCodeModel.setupTimingPattern
  13. QRCodeModel.setupTypeInfo
  14. COLUMN: -1/28
  15. ███████████████████████████████
  16. █       █  █ ██ █   █ █       █
  17. █ █████ █   █ █ █ █ █ █ █████ █
  18. █ █   █ ████ ███      █ █   █ █
  19. █ █   █ █ ███ █████ ███ █   █ █
  20. █ █   █ █  █ ████   █ █ █   █ █
  21. █ █████ █  ██ ██ █   ██ █████ █
  22. █       █ █ █ █ █ █ █ █       █
  23. ██████████ ████ █ ██  █████████
  24. ████ ██ ██ ██  █ █ █████   █  █
  25. █    █████   █ █  ████   ████ █
  26. ███  ██   █ █ ███ █          ██
  27. ███ █  █ █    █████  ██  ██  ██
  28. ██  █ █  █ ████  ██ ███ ███████
  29. ██ █  ███  █ ██  ██    █ █ ████
  30. █████   ██ █████ ██ █  █ ███  █
  31. █ █  █ █  █ ██ █  ███     █████
  32. █    █  █    ████    █ ████████
  33. ██   █████  ██ ███  ██   █ █  █
  34. █ █ █ █ █ ███ █    ███ █  █   █
  35. ███ ██ █   ███     ██ ███  ████
  36. █ ██ █    ██     █  █     █   █
  37. ████████████    █ █ █ ███ ██  █
  38. █       ██  █ █ █  ██ █ █    ██
  39. █ █████ ██  ████    █ ███ █   █
  40. █ █   █ ██ ███ ██████      ██ █
  41. █ █   █ █ █     ███   █ █   █ █
  42. █ █   █ ██ █ ██  █ █ █ █    █ █
  43. █ █████ ███ ████ █    █  ███ ██
  44. █       ██ █   █   ██ █ █  █ ██
  45. ███████████████████████████████
  46. Input data:
复制代码
生成的二维码不能直接扫。
复制到notepad更不行,win11的notepad和win10以前的不一样了。不测试了。
复制到notepad++,一个黑框用两个黑框替换、一个空格用两个空格替换,得到的二维码微信可扫,手机X浏览器扫码插件扫码不给力,扫不出来。
  1. ██████████████████████████████████████████████████████████████
  2. ██              ██    ██  ████  ██      ██  ██              ██
  3. ██  ██████████  ██      ██  ██  ██  ██  ██  ██  ██████████  ██
  4. ██  ██      ██  ████████  ██████            ██  ██      ██  ██
  5. ██  ██      ██  ██  ██████  ██████████  ██████  ██      ██  ██
  6. ██  ██      ██  ██    ██  ████████      ██  ██  ██      ██  ██
  7. ██  ██████████  ██    ████  ████  ██      ████  ██████████  ██
  8. ██              ██  ██  ██  ██  ██  ██  ██  ██              ██
  9. ████████████████████  ████████  ██  ████    ██████████████████
  10. ████████  ████  ████  ████    ██  ██  ██████████      ██    ██
  11. ██        ██████████      ██  ██    ████████      ████████  ██
  12. ██████    ████      ██  ██  ██████  ██                    ████
  13. ██████  ██    ██  ██        ██████████    ████    ████    ████
  14. ████    ██  ██    ██  ████████    ████  ██████  ██████████████
  15. ████  ██    ██████    ██  ████    ████        ██  ██  ████████
  16. ██████████      ████  ██████████  ████  ██    ██  ██████    ██
  17. ██  ██    ██  ██    ██  ████  ██    ██████          ██████████
  18. ██        ██    ██        ████████        ██  ████████████████
  19. ████      ██████████    ████  ██████    ████      ██  ██    ██
  20. ██  ██  ██  ██  ██  ██████  ██        ██████  ██    ██      ██
  21. ██████  ████  ██      ██████          ████  ██████    ████████
  22. ██  ████  ██        ████          ██    ██          ██      ██
  23. ████████████████████████        ██  ██  ██  ██████  ████    ██
  24. ██              ████    ██  ██  ██    ████  ██  ██        ████
  25. ██  ██████████  ████    ████████        ██  ██████  ██      ██
  26. ██  ██      ██  ████  ██████  ████████████            ████  ██
  27. ██  ██      ██  ██  ██          ██████      ██  ██      ██  ██
  28. ██  ██      ██  ████  ██  ████    ██  ██  ██  ██        ██  ██
  29. ██  ██████████  ██████  ████████  ██        ██    ██████  ████
  30. ██              ████  ██      ██      ████  ██  ██    ██  ████
  31. ██████████████████████████████████████████████████████████████
复制代码
二、win7x64
win7下直接复制到记事本,参考12#的方法,一个空格用两个空格替换。
  1. ███████████████████████████████
  2. █              █    █  ██  █      █  █              █
  3. █  █████  █      █  █  █  █  █  █  █████  █
  4. █  █      █  ████  ███            █  █      █  █
  5. █  █      █  █  ███  █████  ███  █      █  █
  6. █  █      █  █    █  ████      █  █  █      █  █
  7. █  █████  █    ██  ██  █      ██  █████  █
  8. █              █  █  █  █  █  █  █  █              █
  9. ██████████  ████  █  ██    █████████
  10. ████  ██  ██  ██    █  █  █████      █    █
  11. █        █████      █  █    ████      ████  █
  12. ███    ██      █  █  ███  █                    ██
  13. ███  █    █  █        █████    ██    ██    ██
  14. ██    █  █    █  ████    ██  ███  ███████
  15. ██  █    ███    █  ██    ██        █  █  ████
  16. █████      ██  █████  ██  █    █  ███    █
  17. █  █    █  █    █  ██  █    ███          █████
  18. █        █    █        ████        █  ████████
  19. ██      █████    ██  ███    ██      █  █    █
  20. █  █  █  █  █  ███  █        ███  █    █      █
  21. ███  ██  █      ███          ██  ███    ████
  22. █  ██  █        ██          █    █          █      █
  23. ████████████        █  █  █  ███  ██    █
  24. █              ██    █  █  █    ██  █  █        ██
  25. █  █████  ██    ████        █  ███  █      █
  26. █  █      █  ██  ███  ██████            ██  █
  27. █  █      █  █  █          ███      █  █      █  █
  28. █  █      █  ██  █  ██    █  █  █  █        █  █
  29. █  █████  ███  ████  █        █    ███  ██
  30. █              ██  █      █      ██  █  █    █  ██
  31. ███████████████████████████████
复制代码
用微信可扫,全选变色后,微信依然可扫。
用X浏览器插件,直接扫不成功,全选变色后,可扫。

三、以上仅测试玩玩,纯bat有局限性,实际有需求还是搭配第三方命令行QR工具简单直接,或者用js。
四、最后膜拜下楼主




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2