[LANG-858] StringEscapeUtils.escapeJava() does not output the escaped surrogate pairs that is Java parsable.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1412408 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed8a178479
commit
e5a1ea6a76
|
@ -36,6 +36,7 @@ import java.util.Iterator;
|
|||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -2189,5 +2190,31 @@ public class StringUtilsTest {
|
|||
assertEquals("\uD800\uDC00", StringEscapeUtils.escapeCsv("\uD800\uDC00"));
|
||||
assertEquals("\uD834\uDD1E", StringEscapeUtils.escapeCsv("\uD834\uDD1E"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.escapeCsv("\uDBFF\uDFFD"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.escapeHtml3("\uDBFF\uDFFD"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.escapeHtml4("\uDBFF\uDFFD"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.escapeXml("\uDBFF\uDFFD"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests LANG-858.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void testEscapeSurrogatePairsLang858() throws Exception {
|
||||
assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeJava("\uDBFF\uDFFD")); //fail LANG-858
|
||||
assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeEcmaScript("\uDBFF\uDFFD")); //fail LANG-858
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnescapeSurrogatePairs() throws Exception {
|
||||
assertEquals("\uD83D\uDE30", StringEscapeUtils.unescapeCsv("\uD83D\uDE30"));
|
||||
// Examples from https://en.wikipedia.org/wiki/UTF-16
|
||||
assertEquals("\uD800\uDC00", StringEscapeUtils.unescapeCsv("\uD800\uDC00"));
|
||||
assertEquals("\uD834\uDD1E", StringEscapeUtils.unescapeCsv("\uD834\uDD1E"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.unescapeCsv("\uDBFF\uDFFD"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.unescapeHtml3("\uDBFF\uDFFD"));
|
||||
assertEquals("\uDBFF\uDFFD", StringEscapeUtils.unescapeHtml4("\uDBFF\uDFFD"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue