summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2021-02-21 18:52:23 +0000
committerAndreas Beeker <kiwiwings@apache.org>2021-02-21 18:52:23 +0000
commit6d10f26718f84591671d7cafdcc009345b9c777e (patch)
tree8ddf2bf546f48259e4940e653932a84559401586
parent62bfbd3c902f3999d37dbf6f7d4fcd0b167ab6e9 (diff)
downloadpoi-6d10f26718f84591671d7cafdcc009345b9c777e.tar.gz
poi-6d10f26718f84591671d7cafdcc009345b9c777e.zip
Use UTF-8 when writing SVG files
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1886768 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/util/SVGFormat.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xslf/util/SVGFormat.java b/src/ooxml/java/org/apache/poi/xslf/util/SVGFormat.java
index 3dd791f7da..1725aa4f10 100644
--- a/src/ooxml/java/org/apache/poi/xslf/util/SVGFormat.java
+++ b/src/ooxml/java/org/apache/poi/xslf/util/SVGFormat.java
@@ -22,7 +22,10 @@ package org.apache.poi.xslf.util;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.svggen.SVGGraphics2D;
@@ -55,7 +58,11 @@ public class SVGFormat implements OutputFormat {
@Override
public void writeSlide(MFProxy proxy, File outFile) throws IOException {
- svgGenerator.stream(outFile.getCanonicalPath(), true);
+ // Batik DEFAULT_XML_ENCODING is ISO-8859-1 ... srsly?!
+ // Unicode entities aren't encoded, so use UTF-8
+ try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(outFile.getCanonicalPath()), StandardCharsets.UTF_8)) {
+ svgGenerator.stream(writer, true);
+ }
}
@Override