Detecting if a character in a String is an emoticon (using Android)

后端 未结 3 1175
庸人自扰
庸人自扰 2021-01-05 07:54

Like the title says. I want to find out if a given java String contains an emoticon.

I can\'t use Character.UnicodeBlock.of(char) == Character.UnicodeBlock.EMO

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 08:02

    Try this...

    if (Integer.parseInt("1f600", 16) <= (int)'☺' && (int)'☺' <= Integer.parseInt("1f64f", 16)) {
        Print.d("Unicode", "groovy!");
    }
    

    This might work because the hexidecimal value and the char value are both being converted to ints.

提交回复
热议问题