Unicode Encoding and decoding issues in QRCode

2019-01-22 22:53发布

问题:

I am trying to generate UTF-8 QRCode so that I can encore accents and Unicode characters.

To test it, I am using many decoding solution :

  1. http://zxing.org/w/decode.jspx - The zxing project also used in Android
  2. http://www.drhu.org/QRCode/QRDecoder.php - a PHP Decoder
  3. http://zbar.sf.net - The ZBar bar code reader - OpenSource and C project for embedded

All of them give me always the same result.

You can try this image works well with Unicode Characters.

But if I am trying to use zxing or Google Chart API to generate the QRCode, I cannot decode it correctly.

I have tried this :

  1. http://chart.apis.google.com/chart?cht=qr&chs=200x200&choe=SHIFT_JIS&chl=R%C3%A9my+Hubscher
  2. http://chart.apis.google.com/chart?cht=qr&chs=200x200&choe=ISO-8859-1&chl=R%C3%A9my+Hubscher
  3. http://chart.apis.google.com/chart?cht=qr&chs=200x200&choe=UTF-8&chl=R%C3%A9my+Hubscher

But all without success.

Do you know how I can do ? Do you know which encoding is used for the working image ?

回答1:

The solution that comes up, is to encode the text in UTF-8 and add a BOM to specify that the string is actually in UTF-8.

Here it works :

  • http://chart.apis.google.com/chart?cht=qr&chs=200x200&choe=UTF-8&chl=%EF%BB%BFR%C3%A9my+Hubscher