Reputation: 49
I have an input stream that contains valid utf8 characters 0xC2 0x85 (U+0085). How can I read and print this correctly in java? using byte array doesn't help i think as 0x85 is out of range. Basically, I need to read utf8 characters coming from a socket in java which contains 0xC2 0x85
Upvotes: 0
Views: 1216
Reputation: 136002
If you have a valid stream in UTF-8 (is) then use
Reader rdr = new InputStreamReader(is, "UTF-8");
this will convert UTF-8 bytes into Java chars
Upvotes: 1