why '?' appears as output while Printing unicode characters in java

后端 未结 5 1912
不思量自难忘°
不思量自难忘° 2020-12-21 08:47

While printing certain unicode characters in java we get output as \'?\'. Why is it so and is there any way to print these characters?

This is my code



        
5条回答
  •  自闭症患者
    2020-12-21 08:48

    Java's default behaviour when reading an invalid unicode character is to replace it with the Replacement Character (\uFFFD). This character is often rendered as a question mark.

    In your case, the text you're reading is not encoded as unicode, it's encoded as something else (Windows-1252 or ISO-8859-1 are probably the most common alternatives if your text is in English).

提交回复
热议问题