I'm trying to build an Android application using the zbar library to scan codes. I generated QRcodes with UTF-8 encoding and am using this Android app to scan them. The text I'm encoding is "L'étoile". I tried the default zbar test program and noticed that it doesn't display accented characters correctly. So I slightly modified its code below in order to debug it and understand why it's failing to display characters correctly.
byte[] bytes = sym.getDataBytes();
String latin1Result = new String(bytes, "ISO8859-1");
String utf8Result = new String(bytes, "UTF-8");
Log.d("CUSTOM_DEBUG_TAG", "result " + sym.getData() + ", string " + sym.getData().toString() + ". latin1 result " + latin1Result + ". utf8 result " + utf8Result);
From the log I get:
CUSTOM_DEBUG_TAG(11987): result L'テゥtoile, string L'テゥtoile. latin1 result L'ï¾ï½©toile. utf8 result L'テゥtoile
I'm a bit lost when it comes to character sets and encodings so please bear with me. From the log above, can I affirm that the zbar library is actually returning a UTF-8 encoded string "L'étoile"? If so, shouldn't it display correctly in the log?
I believe zbar uses iconv and defaults to ISO-8859-1. So I also tried to generate a QRcode with iso-8859-1 encoded text. I then tried to read the QRcode with the Android application and the log showed this:
CUSTOM_DEBUG_TAG(11987): result L'騁oile, string L'騁oile. latin1 result L'é¨oile. utf8 result L'騁oile
So as you can see I'm unable to retrieve the accented string "L'étoile". Obviously, there are concepts I'm unable to grasp and am hoping for some help.
By the way, if I scan the same QRcode with applications such as QR Droid or Zxing, I get the string correctly displayed as "L'étoile" (thus I'm discarding the fact that there could be problems with the QRcode itself).
Thanks