Reputation: 221
I want to create a string that will contain unicode code, but won't convert it on use.
String s = new String("\u010C");
System.out.println(s);
I want this to be output:
\u010C
instead of this:
Č
I want string to actually contain that set of six characters.
Upvotes: 0
Views: 204
Reputation: 26743
Keppil’s answer is obviously the correct one. To display the 4-digit hex number for a given character, you can also do:
System.out.println(String.format("\\u%04x", (int)'Č'));
Upvotes: 0
Reputation: 46209
If you want the output to be
\u010C
You need to escape your backslash:
String s = new String("\\u010C");
System.out.println(s);
Upvotes: 6