On this page you can find a (rudimentary) applet for creating your own QR cods. Basically, a QR code is a type of 2-dimensional barcode. They're almost unknown in the West, but can be found all over the place here in Japan, anywhere from a soft drink label, to a commercial flyer or a pack of tissues. They encode a wide range of information, but are most commonly used to store web page URLs and contact information. Mobile game manufacturers will often use them to provide shortcuts to their i-mode sites, while businessmen have started adding them to their name cards to provide clients with a fast and painless way to save their information to a cell phone. For example, you can see my business card to the left - the tiny QR code contains all the information written on the front, yet only takes a second to scan and save. Furthermore, with recent developments in the standards it is now possible to use them to store much more complex information, including images or even other QR codes.
Virtually every cell phone produced in Japan for the last couple of years has the ability to read and recognize QR codes to one extent or another. The wide spread availabilty of devices capable of scanning QR codes (Japan has a cell phone penetration rate of some 75%) along with the ease of input (just wave the phone in front of the code and you're all set) have resulted in a resounding success for the QR code standard here. (unlike, say, the ill fated :CueCat of the dot-com era a few years back which serves instead as a lesson of how not to market a standard)
Even if you don't have a cell phone capable of reading QR codes, it can still be neat to play around with them, if just to see the possibilities. On this page you can find a simple script that will take the text you input and turn it into a QR code which you can print out or save to your desktop. At the moment the script is quite rudimentary (see "known issues" below) but when I get some time I will try to spruce it up a little. If you're interested in learning more about QR codes (or to see a fully functional example of a QR code generator) go ahead and check out the "further reading" section below.
This is, as mentioned, a pretty rudimentary script. Problems include the following:
- Ugly: The generated QR code spawns as a blank page containing only the code, which is pretty ugly and requires you to use the "back" button to
return to the site. I need to go through the script change it to generate the code in a pop up window.
- Generic QR code: Right now the generator just takes what you input and spawns a plain old QR code. However, the QR code specification actually
permits you to assign data to explicit fields, such as "name", "URL", "phone number" etc. I will add this functionality in the future, but for now, if you
want to see a working demonstration, check out this site.
- Screwed up Japanese input: QR codes, being a Japanese invention, can naturally contain the full range of Japanese characters. Unfortunately, if
you input something in Japanese into the generator, the code that it spits out will not be what you typed, but rather a bunch of "mojibake" (erroneous, nonsense characters). For now, a work around is to go to the "view" menu of your web
browser select "(character) encodings" and then choose "Japanese Shift-JIS". The generator will then correctly encode any Japanese characters you input.
For more information on the issues behind this, check the bottom of the page.
If you're interested in learning more about QR codes, check out the following links:
QR code Primers: Denso Wave's QR code primer (a bit technical and with some odd English), NFG's QR code explanation (better, but informal and less informational)
QR Code Generators: NFG's QR code generator (very nice and complete. I'd like mine to be like this one day), Psytech QR code generator (freely downloadable and runs on your computer. Features live updating of the QR code as you input data which is neat), Swetake QR code generator (Freely downloadable in either php or perl versions. This is the script both I and NFG use - but you will need a server to host it)
Other: QR-code blog (a blog done entirely in QR codes. All in Japanese - you will need a QR code reader/cell phone to read the site.
Technical Stuff: QR code capacities (NTT docomo's page. In Japanese), QR code capacities (eng) (NFG's translated version of the previous page)
Why do I need to change the page encoding to "Japanese Shift-JIS" for the QR code generator to correctly handle the Japanese characters I input?
If you look at the source code for any page on my site, you will notice that I am careful to always specify an appropriate character set for each page, in keeping with W3C standards. Since I use a mix of different languages on the site, many of which - Japanese, for example - contain characters which lie outside of the set of standard 128 ASCII letters - I specify my charset to be UTF-8. You can read more about UTF-8 here, but basically it a character set that attempts to provide an encoding for virtually all the characters found in every language in the world. (Though some have argued that it has been less than successful in this regard).
Because of this simplicity (don't need to worry about changing your encoding declarations on each page depending on content), its relatively progressive nature and full fledged support for all Japanese characters, I - and most other standards minded developers tend to use UTF-8 encoding for sites intended to display, for example, a mix of Japanese and Roman characters. This is true the world over, except for one very notable exception: Japan.
For reasons partly historical, and partly due to inertia, UTF-8 has made little leeway in Japan, and instead the vast majority of Japanese pages written by Japanese people are encoded - when they bother to make a charset declaration at all - in either Shift_JIS, ISO-2022-JP or EUC-JP. These three standards (besides being incompatible and generally a pain in the ass) are also fairly unknown in the west and are one of the reasons why, when you try and run certain Japanese programs on a Western OS you end up with a screenful of garbage instead of legible characters (this is especially a problem with old J-programs and pre-XP versions of Windows).
Anyway, getting to the point: in order to get the QR code generator to accurately include any Japanese characters you put into it, you will need to switch the page encoding of this particular page to "Shift_JIS" (usually "View" - "Character Encoding" - "Japanese Shift-JIS"). Afterward, it should handle Japanese characters without problem. I may change the encoding on this particular page in the future to avoid this issue, but we'll see. I don't know about changing the actual script itself, since it seems PHP itself is almost completely unaware of the existence of UTF-8, let alone how to handle it.
Encoding issues and international charactersets are a fascinating topic to me and one that is certain to become more and more relevant as the internet moves away from its English centric roots and begins to embrace a wider diversity of languages - including many, which are comprised entirely of non-roman characters. For further reading on this subject, I recommend this extremely informative article over on Joel on Software, and the wikipedia entries on both UTF-8 and Internationalized Domain Names