Encoding is to convert common numbers and characters into QR codes. Before coding the QR code, let's talk about the maximum capacity of the QR code.
I. Maximum capacity
The maximum size of a QR code depends on the selected version, error correction level, and encoding mode (Mode: Number, character, multi-byte character, etc ). Take version 1 and level q as an example. It can store 27 pure numbers, 17 mixed letters and numbers, or 11 8-bit bytes of data. If you want to store the same amount of content and increase the error correction level, a higher version is required. Version 1 ~ 9 data capacity and Error Correction Code capacity are as follows:
(Version) |
(Error Correcting level) |
(Count of data code words) |
Count of EC code words |
(Numeric) |
(Alphanumeric) |
8bit |
1 |
L |
19 |
7 |
41 |
25 |
17 |
M |
16 |
10 |
34 |
20 |
14 |
Q |
13 |
13 |
27 |
16 |
11 |
H |
9 |
17 |
17 |
10 |
7 |
2 |
L |
34 |
10 |
77 |
47 |
32 |
M |
28 |
16 |
63 |
38 |
26 |
Q |
22 |
22 |
48 |
29 |
20 |
H |
16 |
28 |
34 |
20 |
14 |
3 |
L |
55 |
15 |
127 |
77 |
53 |
M |
44 |
26 |
101 |
61 |
42 |
Q |
34 |
36 |
77 |
47 |
32 |
H |
26 |
44 |
58 |
35 |
24 |
4 |
L |
80 |
20 |
187 |
114 |
78 |
M |
64 |
36 |
149 |
90 |
62 |
Q |
48 |
52 |
111 |
67 |
46 |
H |
36 |
64 |
82 |
50 |
34 |
5 |
L |
108 |
26 |
255 |
154 |
106 |
M |
86 |
48 |
202 |
122 |
84 |
Q |
62 |
72 |
144 |
87 |
60 |
H |
46 |
88 |
106 |
64 |
44 |
6 |
L |
136 |
36 |
322 |
195 |
134 |
M |
108 |
64 |
255 |
154 |
106 |
Q |
76 |
96 |
175 |
108 |
74 |
H |
60 |
112 |
139 |
84 |
58 |
7 |
L |
156 |
40 |
370 |
224 |
154 |
M |
124 |
72 |
293 |
178 |
122 |
Q |
88 |
108 |
207 |
125 |
86 |
H |
66 |
130 |
154 |
93 |
64 |
8 |
L |
194 |
48 |
461 |
279 |
192 |
M |
154 |
88 |
365 |
221 |
152 |
Q |
110 |
132 |
259 |
157 |
108 |
H |
86 |
156 |
202 |
122 |
84 |
9 |
L |
232 |
60 |
552 |
335 |
230 |
M |
182 |
110 |
432 |
262 |
180 |
Q |
132 |
160 |
312 |
189 |
130 |
H |
100 |
192 |
235 |
143 |
98 |
For more details about the QR code capacity, go to the installation website and visit http://www.denso-wave.com/qrcode/vertable1-e.html.
The following example illustrates how to convert "abcde123" to a QR code conversion method of version 1 and level H.
2. Mode indicator)
The QR code mode is the number, character, 8-bit bytecode, and multi-byte code mentioned above. For different modes, there is a corresponding mode identifier (mode indicator) to help the decoder to match. The mode identifier is a 4bit binary number:
1. Numeric mode: 0001
2. alphanumeric mode: 0010
3. 8bit byte mode: 0100
4. Japanese characters (Kanji mode): 1000
5. Chinese characters (gb2312): 1101
Because the sample text string is a mix of characters, the alphanumeric mode will be selected, and its identification code is: 0010
3. Character Count indicator)
The text string count identifier is used to store the length of the source content string. In the QR code of version 1-9, the length of the text string length identifier is defined:
Number: 10bit
Mixed characters: 9bit
8bit bytecode: 8bit
Multi-byte code: 8bit
In this example, the length of the source text string is 8 characters, and the length of the mixed characters is 9bit. Therefore, 8 characters are encoded as 9-bit binary representation: 000001000
With the mixed character mode identifier code, the total encoding is 0010 000001000
Iv. Data Content Encoding
1. Encoding in digital mode
In digital mode, data is limited to three digit segments, which are divided into several segments. For example, "123456" is divided into "123" and "456", which are encoded into 10-bit binary numbers. The 10bit binary representation of "123" is 0001111011, which is actually 123 of binary.
When the data length is less than three digits, if there is only one digit, It is 4 bits. If there are two digits, it is expressed by 7 bits.
For example, "9876" is divided into "987" and "6", so it is expressed as "1111011011 0110 ".
2. Encoding in mixed character mode
Mixed Character Mode encoding. The character comparison table is as follows:
0 |
0 |
|
A |
10 |
|
K |
20 |
|
U |
30 |
|
+ |
40 |
1 |
1 |
|
B |
11 |
|
L |
21 |
|
V |
31 |
|
- |
41 |
2 |
2 |
|
C |
12 |
|
M |
22 |
|
W |
32 |
|
. |
42 |
3 |
3 |
|
D |
13 |
|
N |
23 |
|
X |
33 |
|
/ |
43 |
4 |
4 |
|
E |
14 |
|
O |
24 |
|
Y |
34 |
|
: |
44 |
5 |
5 |
|
F |
15 |
|
P |
25 |
|
Z |
35 |
6 |
6 |
|
G |
16 |
|
Q |
26 |
|
[Sp] |
36 |
7 |
7 |
|
H |
17 |
|
R |
27 |
|
$ |
37 |
8 |
8 |
|
I |
18 |
|
S |
28 |
|
% |
38 |
9 |
9 |
|
J |
19 |
|
T |
29 |
|
* |
3 |
Encoding method:
The source code is divided into two character segments, as shown below. The first character of each segment is multiplied by 45, and then the second digit is added. Therefore, each segment is converted into a binary code of 11bit. If the number of characters is only one, it is represented by 6 bits.
Example:
|
|
"AB" |
"Cd" |
"E1" |
"23" |
|
|
45*10 + 11 |
45*12 + 13 |
45*14 + 1 |
45*2 + 3 |
|
|
461 |
553 |
631 |
93 |
0010 |
000001000 |
00111001101 |
01000101001 |
01001110111 |
00001011101 |
3. 8-bit bytes of data are directly stored without encoding and conversion.
5. Terminator)
If the character length after encoding is less than the storage capacity of the current version and Error Correction level, supplement "0000" in the future. If the size is full, no Terminator is required. The resulting encoding string is:
0010 000001000 00111001101 01000101001 01001110111 000010111010000
6. code words)
The above code is further grouped by 8 bits to form a code word ):
00100000 01000001 11001101 01000101 00101001 11011100 00101110
If the end data is less than 8 bits, the end is filled with 0:
00100000 01000001 11001101 01000101 00101001 11011100 00101110000
If the encoded data is insufficient for the version and the maximum capacity of the Error Correction level, add "11101100" and "00010001" at the end until all data is filled up. Finally, the QR code for "abcde123" in version 1 and level H is:
00100000 01000001 11001101 01000101 00101001 11011100 0010111011101100
In decimal format:
32 65 205 69 41 220 46 128 236