Data encoding
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.
Example using "https://fast-qr.com/":

For "https://fast-qr.com/", do the following:
With byte_data being :
01101000 01110100 01110100 01110000 01110011 00111010 00101111 00101111 01100110 01100001 01110011 01110100 00101101 01110001 01110010 00101110 01100011 01101111 01101101 00101111
0b0100 (mode)
• 0b010000010100 (length)
• 0b010000010100<byte_data> (data)
• 0b010000010100<byte_data>0000 (terminator)
• 0b010000010100<byte_data>0000 (padding)
• 0b010000010100<byte_data>00001110110000010001... (filling)
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).
Recap:
We had a string, and we converted it to a byte buffer, according to Version, ELC (quality) and Encoding Mode (here, byte).
Made with 🚀 by erwanvivien
Catched a mistake ? Please make an issue