1

I would like eclipse to allow to print and save a unicode code instead of the character (For use in another program after).

String string = "\u2588";

I want the output to be \u2588 not the block character.

First time posting so sorry for anything done wrong :(.

3 Answers3

6
String string = "\\u2588";

If you use two backslashes it does not try to detect the escape sequence.

Maroun
  • 91,013
  • 29
  • 181
  • 233
Simon Fischer
  • 1,158
  • 6
  • 10
3

The backslash \ is an escape character, to print an actual '\' use "\\"

String s = "\\u2588"
Ron
  • 1,377
  • 13
  • 26
-1

Use this code for printing unicode char

String unicodeMessage =
        "\u7686\u3055\u3093\u3001\u3053\u3093\u306b\u3061\u306f";

        PrintStream out = new PrintStream(System.out, true, "UTF-8");
        out.println(unicodeMessage);
Prabhunath Yadav
  • 187
  • 1
  • 14