I'm currently creating something like emoji-keyboard in Android that will show list of emoticon
I don't want to use image, so I need Unicode character for emoji in Java source code to show emoticon in String output.
For example
Unicode Name: FACE WITH TEARS OF JOY 😂
C/C++/Java source code: "\uD83D\uDE02"
http://www.fileformat.info/info/unicode/char/1f602/index.htm
I need Java Unicode like this "\uD83D\uDE02"
because when I output Label with
Label.setText("\uD83D\uDE02");`
it works and shows FACE WITH TEARS OF JOY 😂
I've already googled this and found this list, I just don't understand how \uD83D\uDE02
was generated.
U+1F602
is an Unicode codepoint. Java can read these.
System.out.println(new StringBuilder().appendCodePoint(0x1F602).toString());
If you really need to convert it to the other kind of Unicode scapes, you can iterate through all the chars, and write those hex codes to the output:
for(char c : new StringBuilder().appendCodePoint(0x1F602).toString().toCharArray()) {
System.out.print("\\u" + String.valueOf(Integer.toHexString(c)));
}
System.out.println();