Unicode Encoding and decoding issues in QRCode

…衆ロ難τιáo~ 提交于 2019-12-18 01:18:11

问题


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


来源:https://stackoverflow.com/questions/1612062/unicode-encoding-and-decoding-issues-in-qrcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!