@Test public void testToAscii() throws UnsupportedEncodingException { String s = "h\u00E9h\u00E9"; assertEquals("hehe", StringUtils.toAscii(s)); }
public static String toAscii(String s, boolean normalize) { if (normalize) { s = Normalizer.normalize(s, Normalizer.Form.NFC); } StringBuilder sb = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); }
StringUtils { public static String toAscii(String s, boolean normalize) { if (normalize) { s = Normalizer.normalize(s, Normalizer.Form.NFC); } StringBuilder sb = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); } }
StringUtils { public static String toAscii(String s, boolean normalize) { if (normalize) { s = Normalizer.normalize(s, Normalizer.Form.NFC); } StringBuilder sb = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); } private  StringUtils(); }
StringUtils { public static String toAscii(String s, boolean normalize) { if (normalize) { s = Normalizer.normalize(s, Normalizer.Form.NFC); } StringBuilder sb = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); } private  StringUtils(); static String toAscii(String s, boolean normalize); static String toAscii(String s); static List<String> split(String str, char delimiter, char escape, boolean trim); static String[] split(String str, char delimiter, boolean trim); static String expandVars(String expression, Map<?, ?> properties); }
StringUtils { public static String toAscii(String s, boolean normalize) { if (normalize) { s = Normalizer.normalize(s, Normalizer.Form.NFC); } StringBuilder sb = new StringBuilder(); int n = s.length(); for (int i = 0; i < n; i++) { char c = s.charAt(i); int pos = UNICODE.indexOf(c); if (pos > -1) { sb.append(PLAIN_ASCII.charAt(pos)); } else { sb.append(c); } } return sb.toString(); } private  StringUtils(); static String toAscii(String s, boolean normalize); static String toAscii(String s); static List<String> split(String str, char delimiter, char escape, boolean trim); static String[] split(String str, char delimiter, boolean trim); static String expandVars(String expression, Map<?, ?> properties);  }