This section is dedicated to section
8.3 in the specification.
The first step in our journey, is to encode data as per the spec. We will refer to 8.3 and more specifically to 8.3.4 (byte mode).
If we read the spec, which I will do for you, when encoding for Byte encoding, we don't have to do much.
We will focus on Version 5 with ECL H and Encoding Mode byte for this blog post on how to create your own QRCode Generator.
I have listed bellow the few steps to go through to get our data buffer.
• First add the
mode indicator we find it's 0b0100 for the current encoding.
• Add the length of the data (typically string.length) on
cci bits.
• Add the raw data.
• Add terminator bits, if the buffer has less than four bits remaining, fill the buffer with zeros.
• If the buffer is not full, pad current length to a multiple of 8.
• While the buffer if not full, pad with 0b11101100 (236) then 0b00010001 (17) and repeat until full.
In the end we have:
65, 70, 135, 71, 71, 7, 51, 162, 242, 246, 102, 23, 55, 66, 215, 23, 34, 230, 54, 246, 210, 240, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17, 236, 17
or
01000001 01000110 10000111 01000111 01000111 00000111 00110011 10100010 11110010 11110110 01100110 00010111 00110111 01000010 11010111 00010111 00100010 11100110 00110110 11110110 11010010 11110000 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001 11101100 00010001
We can clearly see the padding at the end (234) and (17).