@Test public void testBetween() { final NumericEntityEscaper nee = NumericEntityEscaper.between('F', 'L'); final String input = "ADFGZ"; final String result = nee.translate(input); assertEquals("Failed to escape numeric entities via the between method", "ADFGZ", result); }
@Test public void testAbove() { final NumericEntityEscaper nee = NumericEntityEscaper.above('F'); final String input = "ADFGZ"; final String result = nee.translate(input); assertEquals("Failed to escape numeric entities via the above method", "ADFGZ", result); }
@Test public void testBelow() { final NumericEntityEscaper nee = NumericEntityEscaper.below('F'); final String input = "ADFGZ"; final String result = nee.translate(input); assertEquals("Failed to escape numeric entities via the below method", "ADFGZ", result); }
@Test public void testSupplementary() { final NumericEntityEscaper nee = new NumericEntityEscaper(); final String input = "\uD803\uDC22"; final String expected = "𐰢"; final String result = nee.translate(input); assertEquals("Failed to escape numeric entities supplementary characters", expected, result); }
protected void writeText(QuickWriter writer, String text) { if (cdata) { writer.write("<![CDATA["); writer.write(NumericEntityEscaper.below(0x20).translate(text)); writer.write("]]>"); } else { super.writeText(writer, text); } } };
/** * Writes an attribute definition. */ protected void writeAttribute( String name, String value) { print( " "); print( name); print( "=\""); // StringEscapeUtils escapes symbols ', < >, &, ", and some control characters // NumericEntityEscaper translates additional control characters \n, \t, ... print( NumericEntityEscaper.below(0x20).translate(StringEscapeUtils.escapeXml11(value))); print( "\""); }