@Test public void testDecodeEmoji() { }
public static String decodeEmoji(String src) { String regex = EncodeUtils.encodeXml("<span class=\"emoji[\\w\\s]*\"></span>"); Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(src); List<String> groups = new ArrayList<>(); List<Integer> starts = new ArrayList<>(); List<Integer> ends = new ArrayList<>(); while (m.find()) { starts.add(m.start()); ends.add(m.end()); groups.add(m.group()); } if (!starts.isEmpty()) { StringBuilder sb = new StringBuilder(src); int offset = 0; for (int i = 0; i < starts.size(); i++) { int s = starts.get(i); int e = ends.get(i); String g = groups.get(i); int pos = offset + s; sb.delete(pos, offset + e); String ng = g; ng = EncodeUtils.decodeXml(g); sb.insert(pos, ng); offset += ng.length() - g.length(); } return sb.toString(); } return src; }
WXUtils { public static String decodeEmoji(String src) { String regex = EncodeUtils.encodeXml("<span class=\"emoji[\\w\\s]*\"></span>"); Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(src); List<String> groups = new ArrayList<>(); List<Integer> starts = new ArrayList<>(); List<Integer> ends = new ArrayList<>(); while (m.find()) { starts.add(m.start()); ends.add(m.end()); groups.add(m.group()); } if (!starts.isEmpty()) { StringBuilder sb = new StringBuilder(src); int offset = 0; for (int i = 0; i < starts.size(); i++) { int s = starts.get(i); int e = ends.get(i); String g = groups.get(i); int pos = offset + s; sb.delete(pos, offset + e); String ng = g; ng = EncodeUtils.decodeXml(g); sb.insert(pos, ng); offset += ng.length() - g.length(); } return sb.toString(); } return src; } }
WXUtils { public static String decodeEmoji(String src) { String regex = EncodeUtils.encodeXml("<span class=\"emoji[\\w\\s]*\"></span>"); Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(src); List<String> groups = new ArrayList<>(); List<Integer> starts = new ArrayList<>(); List<Integer> ends = new ArrayList<>(); while (m.find()) { starts.add(m.start()); ends.add(m.end()); groups.add(m.group()); } if (!starts.isEmpty()) { StringBuilder sb = new StringBuilder(src); int offset = 0; for (int i = 0; i < starts.size(); i++) { int s = starts.get(i); int e = ends.get(i); String g = groups.get(i); int pos = offset + s; sb.delete(pos, offset + e); String ng = g; ng = EncodeUtils.decodeXml(g); sb.insert(pos, ng); offset += ng.length() - g.length(); } return sb.toString(); } return src; }  }
WXUtils { public static String decodeEmoji(String src) { String regex = EncodeUtils.encodeXml("<span class=\"emoji[\\w\\s]*\"></span>"); Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(src); List<String> groups = new ArrayList<>(); List<Integer> starts = new ArrayList<>(); List<Integer> ends = new ArrayList<>(); while (m.find()) { starts.add(m.start()); ends.add(m.end()); groups.add(m.group()); } if (!starts.isEmpty()) { StringBuilder sb = new StringBuilder(src); int offset = 0; for (int i = 0; i < starts.size(); i++) { int s = starts.get(i); int e = ends.get(i); String g = groups.get(i); int pos = offset + s; sb.delete(pos, offset + e); String ng = g; ng = EncodeUtils.decodeXml(g); sb.insert(pos, ng); offset += ng.length() - g.length(); } return sb.toString(); } return src; }  static char getContactChar(IContact contact); static String decodeEmoji(String src); static String getPureName(String name); static String formatHtmlOutgoing(String name, String msg, boolean encode); static String formatHtmlIncoming(WechatMessage m, AbstractFrom from); }
WXUtils { public static String decodeEmoji(String src) { String regex = EncodeUtils.encodeXml("<span class=\"emoji[\\w\\s]*\"></span>"); Pattern p = Pattern.compile(regex, Pattern.MULTILINE); Matcher m = p.matcher(src); List<String> groups = new ArrayList<>(); List<Integer> starts = new ArrayList<>(); List<Integer> ends = new ArrayList<>(); while (m.find()) { starts.add(m.start()); ends.add(m.end()); groups.add(m.group()); } if (!starts.isEmpty()) { StringBuilder sb = new StringBuilder(src); int offset = 0; for (int i = 0; i < starts.size(); i++) { int s = starts.get(i); int e = ends.get(i); String g = groups.get(i); int pos = offset + s; sb.delete(pos, offset + e); String ng = g; ng = EncodeUtils.decodeXml(g); sb.insert(pos, ng); offset += ng.length() - g.length(); } return sb.toString(); } return src; }  static char getContactChar(IContact contact); static String decodeEmoji(String src); static String getPureName(String name); static String formatHtmlOutgoing(String name, String msg, boolean encode); static String formatHtmlIncoming(WechatMessage m, AbstractFrom from);  }