QR CODE Terminator and complement

If we have a HELLO WORLD string to encode, according to the second example above, we can get the following code,

codingNumber of charactersHELLO WORLD code
001000000101101100001011 01111000110 10001011100 10110111000 10011010100 001101

We also need to add a terminator:

codingNumber of charactersHELLO WORLD codeEnd
001000000101101100001011 01111000110 10001011100 10110111000 10011010100 0011010000

Rearrange by 8bits

If all the codes add up is not 8 multiples, we have to add enough 0s afterwards, for example, there are 78 bits in total, so we have to add 2 0s, then divide the groups by 8 bits:

00100000 01011011 00001011 01111000 11010001 01110010 11011100 01001101 01000011 010000 00

Padding Bytes

Finally, if we have not reached the limit of our maximum number of bits, we have to add some Padding Bytes, Padding Bytes is to repeat the following two bytes: 11101100 00010001 (the two binary to decimal is 236 And 17, I don't know why, just know what Spec is written on.) For the maximum Bits limit for each type of error correction for each Version, see Table-7 on page 28 to page 32 of the QR Code Spec . A table.

Suppose we need to encode the Q error correction level of Version 1, then it needs 104 bits at most, and we only have 80 bits above, so we need to fill 24 bits, that is, we need 3 Padding Bytes, we will Add three and get the following code:

00100000 01011011 00001011 01111000 11010001 01110010 11011100 01001101 01000011 01000000  11101100 00010001 11101100

The above code is the data code, called Data Codewords, each 8bits is called a codeword, we also need to add error correction information to these data codes.