summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/org
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-10-13 22:56:18 -0700
committerElliott Hughes <enh@google.com>2014-10-18 13:29:39 -0700
commit3f1a5ebc337e896977bbc75aa2dc370e97805794 (patch)
treef2507d5186f1869435457083d4f9aa24c1f216ff /luni/src/main/java/org
parent73f5c01dd40d1823cb86cb329a38dd8b620d20cb (diff)
downloadlibcore-3f1a5ebc337e896977bbc75aa2dc370e97805794.zip
libcore-3f1a5ebc337e896977bbc75aa2dc370e97805794.tar.gz
libcore-3f1a5ebc337e896977bbc75aa2dc370e97805794.tar.bz2
Improve support for non-BMP characters in XML.
This adds support for writing surrogate pairs out as entity references in KXmlSerializer and for parsing non-BMP entity references in DocumentBuilderImpl. Emoji and XML. Two of my least favorite things together at last. Bug: 17960630 Change-Id: If5e1001faf250e87e6eeebe3449a6ebc115789a1
Diffstat (limited to 'luni/src/main/java/org')
-rw-r--r--luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java b/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
index d1079c8..040a012 100644
--- a/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
+++ b/luni/src/main/java/org/apache/harmony/xml/parsers/DocumentBuilderImpl.java
@@ -416,11 +416,13 @@ class DocumentBuilderImpl extends DocumentBuilder {
private String resolveCharacterReference(String value, int base) {
try {
- int ch = Integer.parseInt(value, base);
- if (ch < 0 || ch > Character.MAX_VALUE) {
- return null;
+ int codePoint = Integer.parseInt(value, base);
+ if (Character.isBmpCodePoint(codePoint)) {
+ return String.valueOf((char) codePoint);
+ } else {
+ char[] surrogatePair = Character.toChars(codePoint);
+ return new String(surrogatePair);
}
- return String.valueOf((char) ch);
} catch (NumberFormatException ex) {
return null;
}