@Test public void testAscii7() throws Exception { StringBuilder sb = new StringBuilder(); sb.append((char)135); sb.append((char)225); sb.append((char)134); String nonAscii7 = sb.toString(); assertEquals("\u0087á\u0086", nonAscii7); String ascii7 = AsciiService.toASCII7(nonAscii7); assertEquals("cat", ascii7); }
public static String toASCII7(final String text) { StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < text.length(); i++) { char src = text.charAt(i); if ((int) src < 128) { sb.append(src); } else { Character newch = null; if ((int) src < 255) { newch = getASCII7Map().get(src); } else { newch = getASCII8Map().get(src); } if (newch == null) { newch = '_'; String message ="No ASCII-8 mapping found for char " + src + " (" + ((int) src) + ")"; LOG.warn(LeoUtils.getHeaderManipulationSafeString(message)); } sb.append(newch.charValue()); } } return sb.toString(); }
AsciiService { public static String toASCII7(final String text) { StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < text.length(); i++) { char src = text.charAt(i); if ((int) src < 128) { sb.append(src); } else { Character newch = null; if ((int) src < 255) { newch = getASCII7Map().get(src); } else { newch = getASCII8Map().get(src); } if (newch == null) { newch = '_'; String message ="No ASCII-8 mapping found for char " + src + " (" + ((int) src) + ")"; LOG.warn(LeoUtils.getHeaderManipulationSafeString(message)); } sb.append(newch.charValue()); } } return sb.toString(); } }
AsciiService { public static String toASCII7(final String text) { StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < text.length(); i++) { char src = text.charAt(i); if ((int) src < 128) { sb.append(src); } else { Character newch = null; if ((int) src < 255) { newch = getASCII7Map().get(src); } else { newch = getASCII8Map().get(src); } if (newch == null) { newch = '_'; String message ="No ASCII-8 mapping found for char " + src + " (" + ((int) src) + ")"; LOG.warn(LeoUtils.getHeaderManipulationSafeString(message)); } sb.append(newch.charValue()); } } return sb.toString(); }  }
AsciiService { public static String toASCII7(final String text) { StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < text.length(); i++) { char src = text.charAt(i); if ((int) src < 128) { sb.append(src); } else { Character newch = null; if ((int) src < 255) { newch = getASCII7Map().get(src); } else { newch = getASCII8Map().get(src); } if (newch == null) { newch = '_'; String message ="No ASCII-8 mapping found for char " + src + " (" + ((int) src) + ")"; LOG.warn(LeoUtils.getHeaderManipulationSafeString(message)); } sb.append(newch.charValue()); } } return sb.toString(); }  static String toASCII7(final String text); static String toASCII8(final String text); }
AsciiService { public static String toASCII7(final String text) { StringBuilder sb = new StringBuilder(text.length()); for (int i = 0; i < text.length(); i++) { char src = text.charAt(i); if ((int) src < 128) { sb.append(src); } else { Character newch = null; if ((int) src < 255) { newch = getASCII7Map().get(src); } else { newch = getASCII8Map().get(src); } if (newch == null) { newch = '_'; String message ="No ASCII-8 mapping found for char " + src + " (" + ((int) src) + ")"; LOG.warn(LeoUtils.getHeaderManipulationSafeString(message)); } sb.append(newch.charValue()); } } return sb.toString(); }  static String toASCII7(final String text); static String toASCII8(final String text);  }