aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java/org/apache/poi/xssf/streaming
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-28 13:52:09 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-28 13:52:09 +0000
commit938646fd24a304d75d706072e586655ab3c92f89 (patch)
tree4685254535d3706f6c77c795f59fc7277d4fbcca /src/ooxml/java/org/apache/poi/xssf/streaming
parent48228df49d1e557e1dac4affc20dd7999881b211 (diff)
downloadpoi-938646fd24a304d75d706072e586655ab3c92f89.tar.gz
poi-938646fd24a304d75d706072e586655ab3c92f89.zip
Bugzilla 52784 - replace ISO control characters with question marks in SXSSF to be consistent with XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1294657 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xssf/streaming')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
index d575e05324..c9a34a4630 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java
@@ -250,6 +250,7 @@ public class SheetDataWriter {
break;
// Special characters
case '\n':
+ case '\r':
if (counter > last) {
_out.write(chars, last, counter - last);
}
@@ -263,13 +264,6 @@ public class SheetDataWriter {
_out.write("&#x9;");
last = counter + 1;
break;
- case '\r':
- if (counter > last) {
- _out.write(chars, last, counter - last);
- }
- _out.write("&#xd;");
- last = counter + 1;
- break;
case 0xa0:
if (counter > last) {
_out.write(chars, last, counter - last);
@@ -278,7 +272,14 @@ public class SheetDataWriter {
last = counter + 1;
break;
default:
- if (c < ' ' || c > 127) {
+ // YK: XmlBeans silently replaces all ISO control characters ( < 32) with question marks.
+ // the same rule applies to unicode surrogates and "not a character" symbols.
+ if( c < ' ' || Character.isLowSurrogate(c) || Character.isHighSurrogate(c) ||
+ ('\uFFFE' <= c && c <= '\uFFFF')) {
+ _out.write('?');
+ last = counter + 1;
+ }
+ else if (c > 127) {
if (counter > last) {
_out.write(chars, last, counter - last);
}