Why there is a difference in how an emoji is displayed in JavaFX depending on if you're using a unicode escaping or not?
var button = new Button("Toggle Pane >\u2699< >⚙️<");
- in first pair of brackets a gear emoji will be placed, but in second pair - there will be a gear emoji and an empty rectangle.
If same Java string will be printed to console instead of being displayed in GUI, there will be no rectangle.
Source .java file is UTF-8, you can paste emoji into text by pressing Win+;
in Windows.
In Powershell there is also a difference:
"⚙️" | Format-Hex -Encoding utf32 | % HexBytes
# result: 99 26 00 00 0F FE 00 00
"`u{2699}" | Format-Hex -Encoding utf32 | % HexBytes
# result: 99 26 00 00
What's going on here?
Invisible symbol after emoji is a variation selector.
Win+;
pastes it into text after emoji. It is invisible character (selected on screenshot) which can be removed from source code after pasting emoji or stripped of by "⚙️".charAt(0)
.
In VSCode you can't select/delete this second char because caret treats this pair of chars as a whole, but in Notepad++ you can select this invisible char and delete it.
What does u'\ufe0f' in an emoji mean? Is it the same if I delete it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With