javascript - Adding junk character in currency symbol while exporting data to CSV -



javascript - Adding junk character in currency symbol while exporting data to CSV -

i getting unusual issue whenever exporting info in csv have currency symbol, has added junk character in info beside currency symbol.

for illustration if info = french republic - admin fee 1 x £100 getting result = french republic - admin fee 1 x £100 when open in excel. code :

<html> <head> <script type="text/javascript"> function createcsv() { var buffer = "france - admin fee 1 x £100"; buffer = "\"" + buffer + "\""; // buffer = "" + euro; //"\u2034"; var uri = "data:text/csv;charset=utf," + encodeuricomponent(buffer); var filename = "invoicedata.csv"; var link = document.createelement("a"); if (link.download !== undefined) { // feature detection // browsers back upwards html5 download attribute link.setattribute("href", uri); link.setattribute("download", filename); } else if (navigator.mssaveblob) { // ie 10+ link.addeventlistener("click", function (event) { var blob = new blob([buffer], { "type": "data:text/csv;charset=utf;" }); navigator.mssaveblob(blob, filename); }, false); } else { // needs implement server side export } link.innerhtml = "export csv"; link.click(); } </script> </head> <body> <input type="button" value="download csv" onclick="createcsv()" /> </body> </html>

when open same in notepad. cannot see junk character. thankful if can me work around.

the character set should utf-8. check unicode £, believe u2034. can find chart here, , lists u+00a3. if have more advanced notepad, notepad++ example, check encoding type when open time. excel can finicky.

javascript html export-to-csv

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -