Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import android.text.TextUtils; public class Main { private static final Map<String, String> UNICODE_TO_CHEAT_SHEET = new HashMap<String, String>(); /** * Replaces instances of Emoji unicode characters with their Emoji-Cheat sheet key * * @param s * @return */ public static String replaceUnicodeEmojis(String s) { if (TextUtils.isEmpty(s)) { return ""; } for (int i = 0; i < s.length(); i++) { String key = s.substring(i, i + 1); if ((Character.isLowSurrogate(key.charAt(0)) || Character.isHighSurrogate(key.charAt(0))) && s.length() > i + 1) { key = s.substring(i, i + 2); } String emoji = UNICODE_TO_CHEAT_SHEET.get(key); if (null != emoji) { s = s.replace(key, emoji); } } return s; } }