Summary: | Add SWT snippet for Unicode usage | ||
---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Lars Vogel <Lars.Vogel> |
Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | laeubi, Lars.Vogel |
Version: | 4.17 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Linux | ||
Whiteboard: |
Description
Lars Vogel
2020-10-23 06:32:01 EDT
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! |