highcharts / export-csv

Highcharts plugin to export chart data to CSV
http://www.highcharts.com/plugin-registry/single/7/Export-CSV
MIT License
76 stars 94 forks source link

Export breaks on UTF-8 characters #50

Closed borys-p closed 9 years ago

borys-p commented 9 years ago

Hi,

Exporting data with UTF-8 characters breaks (at least in Firefox), because window.btoa() works only with ISO-8859-1 characters. The fix that works for me is to replace:

return window.btoa(decodeURIComponent(encodeURIComponent(s)));

with (they both seem to work, I'm not sure which is better):

return window.btoa(unescape(encodeURIComponent(s))); return window.btoa(decodeURIComponent(unescape(encodeURIComponent(s))));

borys-p commented 9 years ago

Looks like the first one works better, the second one still sometimes causes URIError: malformed URI sequence. Even though there were no utf-8 characters in output. Weird.