user1101293
user1101293

Reputation: 49

How can i read valid utf-8 characters 0xC2 0x85 from an input stream which are outside the byte range in java?

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

Answers (1)

Evgeniy Dorofeev
Evgeniy Dorofeev

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

Related Questions