Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

unicode

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

String symbol1="\u200d";
        StringBuilder strg = new StringBuilder("unicodecharacter");
        strg.insert(5,symbol1);
        System.out.println("After insertion...");
        System.out.println(strg.toString());

Output is After insertion... unico?decharacter

like image 716
user2821099 Avatar asked Oct 29 '25 01:10

user2821099


2 Answers

Here's a great article, written by Joel Spolsky, on the topic. It won't directly help you solve your problem, but it will help you understand what's going on. It'll also show you how involved the situation really is.

like image 95
Daniel Kaplan Avatar answered Oct 30 '25 18:10

Daniel Kaplan


You have a character encoding which doesn't match the character you have or the supported characters on the screen.

I would check which encoding you are using through out and try to determine whether you are reading, storing or printing the value correctly.

like image 29
Peter Lawrey Avatar answered Oct 30 '25 16:10

Peter Lawrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!