title: Encoding and decoding byte[] with ZXing
body: <p>I am developping an Android app, and I need to encode and decode a bytes array in a QRCode generated with the ZXing app. My problem is that my message decoded does not exactly match the generated byte array.
  I tried to create a QRCode based on a byte array containing incrementing indexes, i.e.</p>
  
  <pre><code>input = [0, 1, 2, ..., 124, 125, 126, 127, -128, -127,... -3, -2, -1, 0, 1, 2, ...]
  </code></pre>
  
  <p>And after encoding the message in the QRCode and decoding it on the responder side, I obtain the following byte array output:</p>
  
  <pre><code>output = [0, 1, 2, ..., 124, 125, 126, 127, 63, 63,... 63, 63, 63, 0, 1, 2, ...]
  </code></pre>
  
  <p>All the "negative" byte values are turned to ASCII char 63: '?' question mark characters.
  I assume that something is going wrong with the encoding charset, but since I am using ISO-8859-1 which everyone claims to be the solution of such kind of issue (<a href="https://stackoverflow.com/a/2489611/1424133">other topic treating the same kind of issue</a> or <a href="http://code.google.com/p/zxing/issues/detail?id=103" rel="nofollow noreferrer">here</a>), I don't see where is my mistake, or if I am skipping a step during the instanciation of the encoding or the decoding.
  Here is the code that I execute to encode a given byte array:</p>
  
  <pre class="lang-java prettyprint-override"><code>String text = "";
  byte[] res = new byte[272];
  for (int i = 0; i &lt; res.length; i++) {
      res[i] = (byte) (i%256);
  }
  try {
      text = new String(res, "ISO8859_1");
  } catch (UnsupportedEncodingException e) {
      // TODO
  }
  Intent intent = new Intent(Intents.Encode.ACTION);
  Intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
  intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
  intent.putExtra(Intents.Encode.FORMAT, "ISO8859_1");
  intent.putExtra(Intents.Encode.DATA, text);
  intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
  
  boolean useVCard = intent.getBooleanExtra(USE_VCARD_KEY, false);
  QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(activity, intent, dimension, useVCard);
  Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
  </code></pre>
  
  <p>And to decode a QRCode, I send the following Intent</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.qrcodeDecoding);
  
      Intent intent = new Intent(Intents.Scan.ACTION);
      intent.putExtra(Intents.Scan.MODE, Intents.Scan.QR_CODE_MODE);
      startActivityForResult(intent, 0);
  }
  </code></pre>
  
  <p>And wait for Result:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  protected void onActivityResult(int request, int result, Intent data)
  {
      if(request == 0)
      {
          //action
          if(result == RESULT_OK)
          {
              String res = data.getStringExtra(Intents.Scan.RESULT);
              byte[] dat = null;
  
              try{
                      dat = res.getBytes("ISO8859_1");
              } catch(UnsopportedEncodingException e) {
                      //TODO
              }
          }
          else if(result == RESULT_CANCELED)
          {
              //TODO
          }
      }
  
  }
  </code></pre>
  
  <p>Could you please tell me where are my mistakes, or where should I look at?</p>
  
  <p>Thank you a lot,</p>
  
  <p>Franck</p>