Community
Participate
Working Groups
AFAICS we have no example how to use Unicode in SWT. IIRC we also support this in SWT. Can we add one? For example, I struggling to use the close symbol from https://www.fileformat.info/info/unicode/char/274c/index.htm on a SWT label and an example would be helpful.
Btw. I know that I can paste unicode charactors into source code but did not find how to get from Unicode U+274C to the actual Charakter. Label label = new Label.... label.setText("❌" + "⛲");
Christoph, can you help here?
This is not SWT specific, for this particular symbol one can simply create a String the following way: > System.out.println("\u274C"); Of course also > Label label = new Label.... > label.setText("\u274C"); would work. Just take into consideration java only supports "lower" Unicode to be encoded directly, for example emoji symbols[1] requires "higher" Unicode, the are a little bit unconvenient to use, but you can simply use the UTF-8 bytes: > System.out.println(new String(new byte[]{(byte)0xF0, (byte)0x9F, (byte)0x98, (byte)0x81}, StandardCharsets.UTF_8)); [1] https://apps.timwhitlock.info/emoji/tables/unicode
BTW: the link you provided also has this in the table if you scroll down a bit: > C/C++/Java source code "\u274C" 😉
Thanks a lot, Christoph. Very helpful!