EmojiInterpolator { public static String interpolateUnicode(String pattern, String text) { Preconditions.checkNotNull(pattern, "Pattern is required."); if (Strings.isNullOrEmpty(text)) { return text; } UnicodeInterpolator ui = createEmojiInterpolator(pattern); return ui.escape(text); } private  EmojiInterpolator(); static UnicodeInterpolator createEmojiInterpolator(String pattern); static String interpolateAlias(String pattern, String text); static String interpolateUnicode(String pattern, String text);  }
@Test public void emojiCharsTest() { String text = "Lorem ipsum \u2639 dolorem\uD83D\uDD36 and dolorem sit amet"; String replaced = EmojiInterpolator.interpolateUnicode("<img src=\"imgs/{0}.png\" />", text); Assert.assertEquals(replaced, "Lorem ipsum <img src=\"imgs/2639.png\" /> dolorem<img src=\"imgs/1f536.png\" /> and dolorem sit amet"); }