SVG.toDataURL icon indicating copy to clipboard operation
SVG.toDataURL copied to clipboard

Special character in SVG-text-nodes will cause a XML error 5617

Open herr-barus opened this issue 10 years ago • 2 comments
trafficstars

Special character like öäüß in SVG-text-nodes will cause a XML error 5617 when using window.btoa for base64 encoding. console: SVG.toDataURL: using native renderer for png export. THIS MIGHT FAIL. SVG.toDataURL: using standard XMLSerializer.serializeToString SVG.toDataURL: using window.btoa for base64 encoding XML5617: Ungültiges XML-Zeichen. Zeile: 9, Spalte 163

Forcing a custom encoding using the base64.js will work in actual FF, Chrome & Opera, but throws a SecurityError in IE in line 95 of svg_todataurl.js. console: SVG.toDataURL: using native renderer for png export. THIS MIGHT FAIL. SVG.toDataURL: using standard XMLSerializer.serializeToString SVG.toDataURL: using custom base64 encoder SVG.toDataURL: exported image size: 0,0 SCRIPT5022: SecurityError Datei: svg_todataurl.js, Zeile: 95, Spalte: 1

herr-barus avatar Jan 04 '15 02:01 herr-barus

I can confirm the error.

I also tried to encode the character using unicode: ä ---> ä

Still failed with following errors:

SVG.toDataURL: using native renderer for png export. THIS MIGHT FAIL. svg_todataurl.js:46 SVG.toDataURL: using standard XMLSerializer.serializeToString svg_todataurl.js:46 SVG.toDataURL: using window.btoa for base64 encoding svg_todataurl.js:136 Can't export! Maybe your browser doesn't support SVG in img element or SVG input for Canvas drawImage? http://en.wikipedia.org/wiki/SVG#Native_support

ghost avatar Mar 06 '18 10:03 ghost

I have the exact same issue from the cases above. It happens with almost every "special character", such as ä, é, €.

I could fix this using the following method before using the lib: unescape(encodeURIComponent(svgData))

bailon avatar Nov 30 '18 19:11 bailon