AndroidXMLEncoder extends net.sf.okapi.common.encoder.XMLEncoder { String escapeCommon(String text) { text = escapeDoubleQuotes(text); boolean needsAndroidEscapeHTML = needsAndroidEscapeHTML(text); Matcher matcher = ANDROID_HTML.matcher(text); StringBuffer sb = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(sb, Matcher.quoteReplacement((needsAndroidEscapeHTML ? matcher.group(1) : "<") + matcher.group(2) + unescapeUtils.replaceEscapedQuotes(matcher.group(3)) + ">")); } matcher.appendTail(sb); text = sb.toString(); text = escapeLineFeed(text); text = escapeCariageReturn(text); return text; } AndroidXMLEncoder(boolean oldEscaping); @Override String encode(String text, EncoderContext context); String escapeAndroid(String text); String escapeAndroidOld(String text);  }
@Test public void testEscapeCommonAnnotation() { String actual = androidXMLEncoder.escapeCommon("&lt;annotation font=\\\"title_emphasis\\\"&gt;Android&lt;/annotation&gt;!"); assertEquals("<annotation font=\"title_emphasis\">Android</annotation>!", actual); }
@Test public void testEscapeCommonB() { String actual = androidXMLEncoder.escapeCommon("&lt;b&gt;Android&lt;/b&gt;!"); assertEquals("<b>Android</b>!", actual); }