title: Encoding and decoding random byte array with zxing
body: <p>I'm trying to transfer a byte array with QR code, so for testing, I decided to generate a random byte array, encode it as QR code, then decode it. I used ISO-8859-1 to convert byte array to string s.t it does not lose data while transmission:</p>
  
  <p>For encoder side:</p>
  
  <pre><code>byte []buffer = new byte[11];
  com.google.zxing.Writer writer = new QRCodeWriter();
  Random randomGenerator = new Random();
      for(int i=0;i&lt;=10;i++){
          buffer[i]=(byte) randomGenerator.nextInt(254);
      }
     // Log.i("time1","original: "+Arrays.toString(buffer));
      String decoded = null;
      try {
          decoded = new String(buffer, "ISO-8859-1");
      } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          result=writer.encode(decoded, BarcodeFormat.QR_CODE, 500, 500);
      } catch (WriterException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
  </code></pre>
  
  <p>In this way I have converted byte array to QR code, it has no problem.
  But for the receiver side:</p>
  
  <pre><code>LuminanceSource source = new PlanarYUVLuminanceSource(data,640,480,0,0,640,480,false);
  bmtobedecoded = new BinaryBitmap(new HybridBinarizer(source));
  Map&lt;DecodeHintType,Object&gt; mp=new HashMap&lt;DecodeHintType, Object&gt;();
  
  mp.put(DecodeHintType.TRY_HARDER, true);
  try {
      result= qrr.decode(bmtobedecoded,mp);
  } catch (NotFoundException e) {
      Log.i("123","not found");
      e.printStackTrace();
  } catch (ChecksumException e) {
      Log.i("123","checksum");
      e.printStackTrace();
  } catch (FormatException e) {
      Log.i("123","format");
      e.printStackTrace();
  }
  </code></pre>
  
  <p>I tried to decode the generated QR code, but it throws out NotFoundException.
  Can someone help me with this issue?</p>
  
  <p><strong>Update 1</strong>: I confirmed that the decoder works perfectly with the normal QR, I also added DecodeHintType.try_harder but still no good.</p>
  
  <p><strong>Update 2</strong>: To clarify, below is what I did to convert between byte array and string:</p>
  
  <pre><code>Random randomGenerator = new Random();
  for(int i=0;i&lt;=10;i++){
      buffer[i]=(byte) randomGenerator.nextInt(254);
  }
  Log.i("time1","original: "+Arrays.toString(buffer));
  String decoded = null;
  try {
      decoded = new String(buffer, "ISO-8859-1");
  } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  Log.i("time1","encoded string:" + decoded);
  BitMatrix result=null;
  try {
      result=qw.encode(decoded, BarcodeFormat.QR_CODE, 500, 500);
  } catch (WriterException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
  }
  iv.setImageBitmap(encodematrix(result));
  byte[] encoded = null;
  try {
      encoded = decoded.getBytes("ISO-8859-1");
  } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  } 
  Log.i("time1","result byte array:" + java.util.Arrays.toString(encoded));
  </code></pre>
  
  <p>If you run this, you can easily see that you can get exactly the same array in the end. I have no problem with this.</p>
  
  <p><strong>Update 3</strong>: I also tried encoding it using UTF-8, but it loses data, so it cannot be the used in encoder. </p>
  
  <p><strong>Update 4</strong>: Just added:</p>
  
  <pre><code>Map&lt;DecodeHintType,Object&gt; mp=new HashMap&lt;DecodeHintType, Object&gt;();
  mp.put(DecodeHintType.CHARACTER_SET, "ISO-8859-1");
  </code></pre>
  
  <p>in the decoder, still throwing out exception.</p>