I am working on an application to simplify a task concerning CSV files at work. All CSV files are in ISO-8859-15 encoding and I can not change that since they are exported from a tool and after running through my javascript web application, they need to be reimported there.
I load the CSV using FileReaderJS
http://bgrins.github.com/filereader.js/ which I extended to supply readAsText
with the proper encoding, thus converting the input to a UTF-8 string.
Now I modify the string I retrieved from the uploaded CSV and want to offer the result (in variable content
) as a download using FileSaver
https://github.com/eligrey/FileSaver.js using this code:
var bb = new BlobBuilder();
bb.append(content);
saveAs(bb.getBlob("text/plain;charset=iso-8859-15"),"export.csv");
When the file arrives on my machine, it is still UTF-8 though. I figure I will probably have to convert the UTF-8 string to iso-8859-15 encoding myself - which is not a problem as I don't require any non-iso-8859 characters, but I have no idea how to achieve that. I took a brief look at http://www.webtoolkit.info/demo/javascript-utf-8 but that didn't help my.
Does anyone know how to make this work?