Unable to read special characters (Java)

I'm making a chat client using special encryption There is a problem reading letters such as «, ƒ, letters from the input buffer

I read them as byte arrays, and I try to use them

Connection.getInputStream().read();

And also use

BufferedReader myInput = new BufferedReader(
    new InputStreamReader(Connection.getInputStream()));

But there seems to be a problem because it displays them as boxes

Solution

You must ensure that your inputstreamreader uses the same character set to decode bytes into characters, not bytes that the sender encodes characters into bytes View additional constructors for inputstreamreader

You must also ensure that the font used to display characters supports your special characters

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>