避免在Java中打印unicode替换字符 [英] Avoid printing unicode replacement character in Java
问题描述
在Java中,为什么 Character.toString((char)65533)
打印出这个符号:
In Java, why does Character.toString((char) 65533)
print out this symbol: � ?
我有一个Java程序,打印这些字符的所有地方。它的一个大程序。关于我可以做什么以避免这种情况的任何想法?
I have a Java program which prints these characters all over the place. Its a big program. Any ideas on what I can do to avoid this?
推荐答案
最可能的情况之一是, -8859数据使用UTF-8字符集。如果您遇到的字符序列不是有效的UTF-8,那么它将替换为 符号。
One of the most likely scenarios is that you are trying to read ISO-8859 data using the UTF-8 character set. If you come accross a sequence of characters that is not valid UTF-8, then it will be replaced with the � symbol.
检查输入流,确保您使用正确的字符集读取它们。
Check your input streams, and ensure that you read them using the correct character set.
这篇关于避免在Java中打印unicode替换字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!