I am trying to print emoticons on screen using unicode text for emoticons.
From a list of Emoticons from Wiki, I found that these are of the form U+1F6xx__ ie. 5 characters hexadecimal.
How am I supposed to print a smiley with text code as:
U+1F60A
Please help.
To print any character in the Python interpreter, use a \u to denote a unicode character and then follow with the character code. For instance, the code for Ī² is 03B2, so to print Ī² the command is print('\u03B2') . There are a couple of special characters that will combine symbols.
The maximum possible number of code points Unicode can support is 1,114,112 through seventeen 16-bit planes. Each plane can support 65,536 different code points. Among the more than one million code points that Unicode can support, version 4.0 curently defines 96,382 characters at plane 0, 1, 2, and 14.
We can put the Unicode value with the prefix \u. Thus we can successfully print the Unicode character.
The ord function in python accepts a single character as an argument and returns an integer value representing the Unicode equivalent of that character.
Try the next with some font with support for this characters:
public static void main(String[] args) {
for (int codePoint = 0x1F600; codePoint <= 0x1F64F;) {
System.out.print(Character.toChars(codePoint));
codePoint++;
if (codePoint % 16 == 0) {
System.out.println();
}
}
}
Output:
šššššš
šššššššššš
šššššššššššššššš
š š”š¢š£š¤š„š¦š§šØš©šŖš«š¬šš®šÆ
š°š±š²š³š“šµš¶š·šøš¹šŗš»š¼š½š¾šæ
šššššš
šššššššššš
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