I have the following code to convert unicode to bytes, it works:
byte[] emojiBytes = new byte[]{(byte)0xF0,(byte)0x9F,(byte)0x98,(byte)0x81};
String emojiAsString = new String(emojiBytes,Charset.forName("UTF-8"));
// JButton button = new JButton("<html>" + emojiAsString + "</html>");
JButton button = new JButton(emojiAsString);
But what if I only know the unicode like this : 1F601
, 1F603
, I want to convert symbols on this page : https://apps.timwhitlock.info/emoji/tables/unicode
Given a string like 1F601
, how do I convert it to \xF0\x9F\x98\x81
then to new byte[]{(byte)0xF0,(byte)0x9F,(byte)0x98,(byte)0x81}
?
So to simplify, my code would look like this:
JButton getButton(String unicodeText)
{
JButton aButton= // how to convert ???
return aButton;
}
Then I call it like this: JButton myButton=getButton("1F601");