Can we generate QR codes directly in javascript?
It is surprisingly easy actually. Javascript interpreters have come a long way. I wrote the Reed Solomon encoder first, based on Phil Karn’s implementation. It is really fast, and was very easy to write. Now a decoder might be a bit harder, but encoding is surprisingly easy, and definitely does not need all those complicated object oriented approaches you see out there.
One of the hardest parts actually was the bit-encoding of the message. You see the bit-encoding is different at different densities of the QR code, but you choose the density based on the length of the code. So I had to write a two-pass input gatherer: first compute the lengths in the three different encodings, then encode in the chosen encoding. After that the encoding was pretty simple, though writing a bit-array was way harder than it should have been. 8 little endians all in a row.
All that is left right now is writing down the location of the alignment codes in general (I have version 1 and 2 hard coded), writing the version information for version higher than 7, and choosing the “correct” mask, rather than just letting the user decide.
I really enjoy these little engineering code projects. I wrote a voip app using speex, a bubble reader using some CS books (haha, wow it was slow), and a big barcoded paper wrangler project using google’s zxing library and itext’s pdf generator. It’s really amazing how much of the world is accessible. I still haven’t built an amplifier or a car, but my (single) transistor radio was awesome.