title: Android java utf-8 encoded strings
body: <p>I'm trying to build an Android application using the <a href="http://zbar.sourceforge.net/" rel="nofollow">zbar</a> 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.</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>From the log I get:</p>
  
  <pre><code>CUSTOM_DEBUG_TAG(11987): result L'ﾃｩtoile, string L'ﾃｩtoile. latin1 result L'ï¾ï½©toile. utf8 result L'ﾃｩtoile
  </code></pre>
  
  <p>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?</p>
  
  <p>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:</p>
  
  <pre><code>CUSTOM_DEBUG_TAG(11987): result L'騁oile, string L'騁oile. latin1 result L'é¨oile. utf8 result L'騁oile
  </code></pre>
  
  <p>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.</p>
  
  <p>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).</p>
  
  <p>Thanks</p>