我在谷歌上搜索并阅读了大量关于二维码和基于各种设置可以使用的最大数据的信息,所有这些都是表格格式的。我似乎找不到任何给出公式或如何计算这些值的正确解释。
我想做的是这样的:
交易完成。这部分很简单。
我想添加的内容是“剩余字符数”,以便他们(用户)可以看到他们还可以输入多少数据,以及这些属性对 QR 码的存储容量有何影响。
有人知道在哪里可以找到公式吗?或者我需要购买ISO 18004:2006?
计算可以放入二维码中的数据量的公式制作起来相当复杂,更不用说它需要一些近似值才能进行计算。该公式必须根据 QRCode 的版本计算专用于 QRCode 中数据的模块数量,然后计算将使用多少个码字(8 个模块的集合)进行纠错。
要计算将用于数据的模块数量,您需要知道有多少模块将用于功能模式。虽然这对于三个查找器模式、时间或版本/格式信息来说不是问题,但对齐模式会出现问题,因为它们的数量取决于 QRCode 的版本,这意味着您无论如何都必须使用以下表格:那一点。
对于第二部分,我不得不说我不知道如何根据纠错能力来计算纠错码字的数量。由于某种原因,需要使用更多的纠错码字来匹配纠错能力,例如 6-H QRCode 可以纠正高达 32.6% 的数据,而不是 H 纠错级别设置的 30% .
无论如何,正如您所看到的,公式的实现起来相当复杂。使用已经建议的表格可能是您能做的最好的事情。
我早在 90 年代就为 Denso Corporation 编写了 QR 码的原始 AIM 规范,并且还是 ISO/IEC 18004 标准两个版本的项目编辑。 对于开发代码打印软件的人来说,使用查找表而不是根据公式计算容量要容易得多 - 这不是一件容易的事,因为在将文本解析为结果时必须迭代考虑几个自变量。被编码以最小化其比特长度,以获得最小的符号。 最关键的因素是数据中字符的混合、数字、字母数字、汉字数据的子字符串的序列和长度,以及表示字符集每次更改所需的开销,以及所需的纠错级别。 我确实为此编写了一个指导部分,该部分包含在 ISO 标准中。
没有公式,但如果有人需要,这里有表格(?或列表):
private readonly static QRVersionDataLimit[,] qRVersionDataLimits = InitQRVersionDataLimits();
private static QRVersionDataLimit[,] InitQRVersionDataLimits()
{
var results = new QRVersionDataLimit[41, 4];
results[1, 0] = new QRVersionDataLimit { nm = 41, am = 25, bm = 17, km = 10 };
results[1, 1] = new QRVersionDataLimit { nm = 34, am = 20, bm = 14, km = 8 };
results[1, 2] = new QRVersionDataLimit { nm = 27, am = 16, bm = 11, km = 7 };
results[1, 3] = new QRVersionDataLimit { nm = 17, am = 10, bm = 7, km = 4 };
results[2, 0] = new QRVersionDataLimit { nm = 77, am = 47, bm = 32, km = 20 };
results[2, 1] = new QRVersionDataLimit { nm = 63, am = 38, bm = 26, km = 16 };
results[2, 2] = new QRVersionDataLimit { nm = 48, am = 29, bm = 20, km = 12 };
results[2, 3] = new QRVersionDataLimit { nm = 34, am = 20, bm = 14, km = 8 };
results[3, 0] = new QRVersionDataLimit { nm = 127, am = 77, bm = 53, km = 32 };
results[3, 1] = new QRVersionDataLimit { nm = 101, am = 61, bm = 42, km = 26 };
results[3, 2] = new QRVersionDataLimit { nm = 77, am = 47, bm = 32, km = 20 };
results[3, 3] = new QRVersionDataLimit { nm = 58, am = 35, bm = 24, km = 15 };
results[4, 0] = new QRVersionDataLimit { nm = 187, am = 114, bm = 78, km = 48 };
results[4, 1] = new QRVersionDataLimit { nm = 149, am = 90, bm = 62, km = 38 };
results[4, 2] = new QRVersionDataLimit { nm = 111, am = 67, bm = 46, km = 28 };
results[4, 3] = new QRVersionDataLimit { nm = 82, am = 50, bm = 34, km = 21 };
results[5, 0] = new QRVersionDataLimit { nm = 255, am = 154, bm = 106, km = 65 };
results[5, 1] = new QRVersionDataLimit { nm = 202, am = 122, bm = 84, km = 52 };
results[5, 2] = new QRVersionDataLimit { nm = 144, am = 87, bm = 60, km = 37 };
results[5, 3] = new QRVersionDataLimit { nm = 106, am = 64, bm = 44, km = 27 };
results[6, 0] = new QRVersionDataLimit { nm = 322, am = 195, bm = 134, km = 82 };
results[6, 1] = new QRVersionDataLimit { nm = 255, am = 154, bm = 106, km = 65 };
results[6, 2] = new QRVersionDataLimit { nm = 178, am = 108, bm = 74, km = 45 };
results[6, 3] = new QRVersionDataLimit { nm = 139, am = 84, bm = 58, km = 36 };
results[7, 0] = new QRVersionDataLimit { nm = 370, am = 224, bm = 154, km = 95 };
results[7, 1] = new QRVersionDataLimit { nm = 293, am = 178, bm = 122, km = 75 };
results[7, 2] = new QRVersionDataLimit { nm = 207, am = 125, bm = 86, km = 53 };
results[7, 3] = new QRVersionDataLimit { nm = 154, am = 93, bm = 64, km = 39 };
results[8, 0] = new QRVersionDataLimit { nm = 461, am = 279, bm = 192, km = 118 };
results[8, 1] = new QRVersionDataLimit { nm = 365, am = 221, bm = 152, km = 93 };
results[8, 2] = new QRVersionDataLimit { nm = 259, am = 157, bm = 108, km = 66 };
results[8, 3] = new QRVersionDataLimit { nm = 202, am = 122, bm = 84, km = 52 };
results[9, 0] = new QRVersionDataLimit { nm = 552, am = 335, bm = 230, km = 141 };
results[9, 1] = new QRVersionDataLimit { nm = 432, am = 262, bm = 180, km = 111 };
results[9, 2] = new QRVersionDataLimit { nm = 312, am = 189, bm = 130, km = 80 };
results[9, 3] = new QRVersionDataLimit { nm = 235, am = 143, bm = 98, km = 60 };
results[10, 0] = new QRVersionDataLimit { nm = 652, am = 395, bm = 271, km = 167 };
results[10, 1] = new QRVersionDataLimit { nm = 513, am = 311, bm = 213, km = 131 };
results[10, 2] = new QRVersionDataLimit { nm = 364, am = 221, bm = 151, km = 93 };
results[10, 3] = new QRVersionDataLimit { nm = 288, am = 174, bm = 119, km = 74 };
results[11, 0] = new QRVersionDataLimit { nm = 772, am = 468, bm = 321, km = 198 };
results[11, 1] = new QRVersionDataLimit { nm = 604, am = 366, bm = 251, km = 155 };
results[11, 2] = new QRVersionDataLimit { nm = 427, am = 259, bm = 177, km = 109 };
results[11, 3] = new QRVersionDataLimit { nm = 331, am = 200, bm = 137, km = 85 };
results[12, 0] = new QRVersionDataLimit { nm = 883, am = 535, bm = 367, km = 226 };
results[12, 1] = new QRVersionDataLimit { nm = 691, am = 419, bm = 287, km = 177 };
results[12, 2] = new QRVersionDataLimit { nm = 489, am = 296, bm = 203, km = 125 };
results[12, 3] = new QRVersionDataLimit { nm = 374, am = 227, bm = 155, km = 96 };
results[13, 0] = new QRVersionDataLimit { nm = 1022, am = 619, bm = 425, km = 262 };
results[13, 1] = new QRVersionDataLimit { nm = 796, am = 483, bm = 331, km = 204 };
results[13, 2] = new QRVersionDataLimit { nm = 580, am = 352, bm = 241, km = 149 };
results[13, 3] = new QRVersionDataLimit { nm = 427, am = 259, bm = 177, km = 109 };
results[14, 0] = new QRVersionDataLimit { nm = 1101, am = 667, bm = 458, km = 282 };
results[14, 1] = new QRVersionDataLimit { nm = 871, am = 528, bm = 362, km = 223 };
results[14, 2] = new QRVersionDataLimit { nm = 621, am = 376, bm = 258, km = 159 };
results[14, 3] = new QRVersionDataLimit { nm = 468, am = 283, bm = 194, km = 120 };
results[15, 0] = new QRVersionDataLimit { nm = 1250, am = 758, bm = 520, km = 320 };
results[15, 1] = new QRVersionDataLimit { nm = 991, am = 600, bm = 412, km = 254 };
results[15, 2] = new QRVersionDataLimit { nm = 703, am = 426, bm = 292, km = 180 };
results[15, 3] = new QRVersionDataLimit { nm = 530, am = 321, bm = 220, km = 136 };
results[16, 0] = new QRVersionDataLimit { nm = 1408, am = 854, bm = 586, km = 361 };
results[16, 1] = new QRVersionDataLimit { nm = 1082, am = 656, bm = 450, km = 277 };
results[16, 2] = new QRVersionDataLimit { nm = 775, am = 470, bm = 322, km = 198 };
results[16, 3] = new QRVersionDataLimit { nm = 602, am = 365, bm = 250, km = 154 };
results[17, 0] = new QRVersionDataLimit { nm = 1548, am = 938, bm = 644, km = 397 };
results[17, 1] = new QRVersionDataLimit { nm = 1212, am = 734, bm = 504, km = 310 };
results[17, 2] = new QRVersionDataLimit { nm = 876, am = 531, bm = 364, km = 224 };
results[17, 3] = new QRVersionDataLimit { nm = 674, am = 408, bm = 280, km = 173 };
results[18, 0] = new QRVersionDataLimit { nm = 1725, am = 1046, bm = 718, km = 442 };
results[18, 1] = new QRVersionDataLimit { nm = 1346, am = 816, bm = 560, km = 345 };
results[18, 2] = new QRVersionDataLimit { nm = 948, am = 574, bm = 394, km = 243 };
results[18, 3] = new QRVersionDataLimit { nm = 746, am = 452, bm = 310, km = 191 };
results[19, 0] = new QRVersionDataLimit { nm = 1903, am = 1153, bm = 792, km = 488 };
results[19, 1] = new QRVersionDataLimit { nm = 1500, am = 909, bm = 624, km = 384 };
results[19, 2] = new QRVersionDataLimit { nm = 1063, am = 644, bm = 442, km = 272 };
results[19, 3] = new QRVersionDataLimit { nm = 813, am = 493, bm = 338, km = 208 };
results[20, 0] = new QRVersionDataLimit { nm = 2061, am = 1249, bm = 858, km = 528 };
results[20, 1] = new QRVersionDataLimit { nm = 1600, am = 970, bm = 666, km = 410 };
results[20, 2] = new QRVersionDataLimit { nm = 1159, am = 702, bm = 482, km = 297 };
results[20, 3] = new QRVersionDataLimit { nm = 919, am = 557, bm = 382, km = 235 };
results[21, 0] = new QRVersionDataLimit { nm = 2232, am = 1352, bm = 929, km = 572 };
results[21, 1] = new QRVersionDataLimit { nm = 1708, am = 1035, bm = 711, km = 438 };
results[21, 2] = new QRVersionDataLimit { nm = 1224, am = 742, bm = 509, km = 314 };
results[21, 3] = new QRVersionDataLimit { nm = 969, am = 587, bm = 403, km = 248 };
results[22, 0] = new QRVersionDataLimit { nm = 2409, am = 1460, bm = 1003, km = 618 };
results[22, 1] = new QRVersionDataLimit { nm = 1872, am = 1134, bm = 779, km = 480 };
results[22, 2] = new QRVersionDataLimit { nm = 1358, am = 823, bm = 565, km = 348 };
results[22, 3] = new QRVersionDataLimit { nm = 1056, am = 640, bm = 439, km = 270 };
results[23, 0] = new QRVersionDataLimit { nm = 2620, am = 1588, bm = 1091, km = 672 };
results[23, 1] = new QRVersionDataLimit { nm = 2059, am = 1248, bm = 857, km = 528 };
results[23, 2] = new QRVersionDataLimit { nm = 1468, am = 890, bm = 611, km = 376 };
results[23, 3] = new QRVersionDataLimit { nm = 1108, am = 672, bm = 461, km = 284 };
results[24, 0] = new QRVersionDataLimit { nm = 2812, am = 1704, bm = 1171, km = 721 };
results[24, 1] = new QRVersionDataLimit { nm = 2188, am = 1326, bm = 911, km = 561 };
results[24, 2] = new QRVersionDataLimit { nm = 1588, am = 963, bm = 661, km = 407 };
results[24, 3] = new QRVersionDataLimit { nm = 1228, am = 744, bm = 511, km = 315 };
results[25, 0] = new QRVersionDataLimit { nm = 3057, am = 1853, bm = 1273, km = 784 };
results[25, 1] = new QRVersionDataLimit { nm = 2395, am = 1451, bm = 997, km = 614 };
results[25, 2] = new QRVersionDataLimit { nm = 1718, am = 1041, bm = 715, km = 440 };
results[25, 3] = new QRVersionDataLimit { nm = 1286, am = 779, bm = 535, km = 330 };
results[26, 0] = new QRVersionDataLimit { nm = 3283, am = 1990, bm = 1367, km = 842 };
results[26, 1] = new QRVersionDataLimit { nm = 2544, am = 1542, bm = 1059, km = 652 };
results[26, 2] = new QRVersionDataLimit { nm = 1804, am = 1094, bm = 751, km = 462 };
results[26, 3] = new QRVersionDataLimit { nm = 1425, am = 864, bm = 593, km = 365 };
results[27, 0] = new QRVersionDataLimit { nm = 3517, am = 2132, bm = 1465, km = 902 };
results[27, 1] = new QRVersionDataLimit { nm = 2701, am = 1637, bm = 1125, km = 692 };
results[27, 2] = new QRVersionDataLimit { nm = 1933, am = 1172, bm = 805, km = 496 };
results[27, 3] = new QRVersionDataLimit { nm = 1501, am = 910, bm = 625, km = 385 };
results[28, 0] = new QRVersionDataLimit { nm = 3669, am = 2223, bm = 1528, km = 940 };
results[28, 1] = new QRVersionDataLimit { nm = 2857, am = 1732, bm = 1190, km = 732 };
results[28, 2] = new QRVersionDataLimit { nm = 2085, am = 1263, bm = 868, km = 534 };
results[28, 3] = new QRVersionDataLimit { nm = 1581, am = 958, bm = 658, km = 405 };
results[29, 0] = new QRVersionDataLimit { nm = 3909, am = 2369, bm = 1628, km = 1002 };
results[29, 1] = new QRVersionDataLimit { nm = 3035, am = 1839, bm = 1264, km = 778 };
results[29, 2] = new QRVersionDataLimit { nm = 2181, am = 1322, bm = 908, km = 559 };
results[29, 3] = new QRVersionDataLimit { nm = 1677, am = 1016, bm = 698, km = 430 };
results[30, 0] = new QRVersionDataLimit { nm = 4158, am = 2520, bm = 1732, km = 1066 };
results[30, 1] = new QRVersionDataLimit { nm = 3289, am = 1994, bm = 1370, km = 843 };
results[30, 2] = new QRVersionDataLimit { nm = 2358, am = 1429, bm = 982, km = 604 };
results[30, 3] = new QRVersionDataLimit { nm = 1782, am = 1080, bm = 742, km = 457 };
results[31, 0] = new QRVersionDataLimit { nm = 4417, am = 2677, bm = 1840, km = 1132 };
results[31, 1] = new QRVersionDataLimit { nm = 3486, am = 2113, bm = 1452, km = 894 };
results[31, 2] = new QRVersionDataLimit { nm = 2473, am = 1499, bm = 1030, km = 634 };
results[31, 3] = new QRVersionDataLimit { nm = 1897, am = 1150, bm = 790, km = 486 };
results[32, 0] = new QRVersionDataLimit { nm = 4686, am = 2840, bm = 1952, km = 1201 };
results[32, 1] = new QRVersionDataLimit { nm = 3693, am = 2238, bm = 1538, km = 947 };
results[32, 2] = new QRVersionDataLimit { nm = 2670, am = 1618, bm = 1112, km = 684 };
results[32, 3] = new QRVersionDataLimit { nm = 2022, am = 1226, bm = 842, km = 518 };
results[33, 0] = new QRVersionDataLimit { nm = 4965, am = 3009, bm = 2068, km = 1273 };
results[33, 1] = new QRVersionDataLimit { nm = 3909, am = 2369, bm = 1628, km = 1002 };
results[33, 2] = new QRVersionDataLimit { nm = 2805, am = 1700, bm = 1168, km = 719 };
results[33, 3] = new QRVersionDataLimit { nm = 2157, am = 1307, bm = 898, km = 553 };
results[34, 0] = new QRVersionDataLimit { nm = 5253, am = 3183, bm = 2188, km = 1347 };
results[34, 1] = new QRVersionDataLimit { nm = 4134, am = 2506, bm = 1722, km = 1060 };
results[34, 2] = new QRVersionDataLimit { nm = 2949, am = 1787, bm = 1228, km = 756 };
results[34, 3] = new QRVersionDataLimit { nm = 2301, am = 1394, bm = 958, km = 590 };
results[35, 0] = new QRVersionDataLimit { nm = 5529, am = 3351, bm = 2303, km = 1417 };
results[35, 1] = new QRVersionDataLimit { nm = 4343, am = 2632, bm = 1809, km = 1113 };
results[35, 2] = new QRVersionDataLimit { nm = 3081, am = 1867, bm = 1283, km = 790 };
results[35, 3] = new QRVersionDataLimit { nm = 2361, am = 1431, bm = 983, km = 605 };
results[36, 0] = new QRVersionDataLimit { nm = 5836, am = 3537, bm = 2431, km = 1496 };
results[36, 1] = new QRVersionDataLimit { nm = 4588, am = 2780, bm = 1911, km = 1176 };
results[36, 2] = new QRVersionDataLimit { nm = 3244, am = 1966, bm = 1351, km = 832 };
results[36, 3] = new QRVersionDataLimit { nm = 2524, am = 1530, bm = 1051, km = 647 };
results[37, 0] = new QRVersionDataLimit { nm = 6153, am = 3729, bm = 2563, km = 1577 };
results[37, 1] = new QRVersionDataLimit { nm = 4775, am = 2894, bm = 1989, km = 1224 };
results[37, 2] = new QRVersionDataLimit { nm = 3417, am = 2071, bm = 1423, km = 876 };
results[37, 3] = new QRVersionDataLimit { nm = 2625, am = 1591, bm = 1093, km = 673 };
results[38, 0] = new QRVersionDataLimit { nm = 6479, am = 3927, bm = 2699, km = 1661 };
results[38, 1] = new QRVersionDataLimit { nm = 5039, am = 3054, bm = 2099, km = 1292 };
results[38, 2] = new QRVersionDataLimit { nm = 3599, am = 2181, bm = 1499, km = 923 };
results[38, 3] = new QRVersionDataLimit { nm = 2735, am = 1658, bm = 1139, km = 701 };
results[39, 0] = new QRVersionDataLimit { nm = 6743, am = 4087, bm = 2809, km = 1729 };
results[39, 1] = new QRVersionDataLimit { nm = 5313, am = 3220, bm = 2213, km = 1362 };
results[39, 2] = new QRVersionDataLimit { nm = 3791, am = 2298, bm = 1579, km = 972 };
results[39, 3] = new QRVersionDataLimit { nm = 2927, am = 1774, bm = 1219, km = 750 };
results[40, 0] = new QRVersionDataLimit { nm = 7089, am = 4296, bm = 2953, km = 1817 };
results[40, 1] = new QRVersionDataLimit { nm = 5596, am = 3391, bm = 2331, km = 1435 };
results[40, 2] = new QRVersionDataLimit { nm = 3993, am = 2420, bm = 1663, km = 1024 };
results[40, 3] = new QRVersionDataLimit { nm = 3057, am = 1852, bm = 1273, km = 784 };
return results;
}
public struct QRVersionDataLimit
{
/// <summary>
/// pure number
/// </summary>
public short nm;
/// <summary>
/// letter + number
/// </summary>
public short am;
/// <summary>
/// Binary
/// </summary>
public short bm;
/// <summary>
/// Kanji
/// </summary>
public short km;
}
存储空间根据二维码模式和您使用的版本/类型计算。更具体地说,计算基于字符的“可压缩性”程度以及允许 qr 生成器对当前内容使用什么算法。