We are trying to let our application accept emojis. We are trying to limit the emojis to the ones from this list.
So, i am trying to read the unicode value (for example, U+1F600 for ) for emojis - so i can validate that the user entered emoji is from the above list.
can somebody please help me with how to read the unicode value for an emoji? or any other ways i can implement this validation ? using encoded values etc.?
}
String actualEmojiString = "";
for(int i=0; i< actualEmojiString.codePointCount(0, actualEmojiString.length()); i++) {
int codePoint = actualEmojiString.charAt(i);
if(Character.isSurrogate(actualEmojiString.charAt(i))) {
codePoint = Character.toCodePoint(actualEmojiString.charAt(i), actualEmojiString.charAt(i));
}
System.out.println( "HexCode value for emoji: [" + actualEmojiString.charAt(i) + "] is [" +"U+" + Integer.toHexString(codePoint | 0x10000).substring(0) +"]"
+ "["+"\\u" + Integer.toHexString(codePoint | 0x10000).substring(1) + "]");
Output:
HexCode value for emoji: [?] is [U+1f03d][\uf03d]
HexCode value for emoji: [?] is [U+190200][\u90200]