title: Java Byte to Char conversion
body: <p>I read from a TCP/IP socket s:</p>
  
  <pre><code>byte[] bbuf = new byte[30];
  s.getInputStream().read(bbuf);
  for (int i = 0; i &lt; bbuf.length; i++)
  {
       System.out.println(Integer.toHexString( (int) (bbuf[i] &amp; 0xff)));
  }
  </code></pre>
  
  <p>This outputs CA 68 9F 75 which is what I would expect. Now I want to use chars instead</p>
  
  <pre><code>char[] cbuf = new char[30];
  BufferedReader input =  new BufferedReader(new InputStreamReader(s.getInputStream())); 
  for (int i = 0; i &lt; cbuf.length; i++)
  {
       System.out.println(Integer.toHexString( (int) (cbuf[i] )));
  }
  </code></pre>
  
  <p>Now the output is CA 68 178 75. So the third Byte (and only the third byte) makes the difference. I assume it has to do with the character sets and that I have to specify a character set in the InputStreamer. I have no idea how to find out what character set I have to use. Secondly I am surprised if it is due to character sets that I only get the mess with exactly one character. I tried all kind of other characters but that seems to be the only one I was able to find.</p>
  
  <p>Who can solve the mystery?</p>