1. 程式人生 > >Android將系統emoji表情轉換成十進位制字串

Android將系統emoji表情轉換成十進位制字串

public static String getIngeger(String s) {
    int a = 0;
String aa = "";
String sss = "";
    int b = 0;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
       //判斷是否為表情
if (isEmojiCharacter(c)) {
            b++;
            int i1 = c - 48;//轉為ascilla += i1;            if (b % 2 
== 0) { aa =(a + 16419) + ";"; a = 0; b = 0; sss = sss + aa; } } else { sss = sss + new String(Character.toString(c)); } } return sss; }
private static boolean isEmojiCharacter(char codePoint) {
     return !((codePoint == 0x0) || (codePoint == 0x9) || (codePoint == 0xA
) || (codePoint == 0xD) || ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))); }