asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

How to use charset attribute? #109

Open altukhov-a opened 8 years ago

altukhov-a commented 8 years ago

Hi, I try to change default charset for csv file <button class="btn btn-success" ng-csv="getArray" field-separator=";" charset="windows-1251" csv-header="getHeader()" filename="test.csv">Export</button> But when I download and save file it saved with UTF-8 encoding What did I do wrong?

Phoenix1978 commented 8 years ago

hello, I have the same problem as you. I tried also with charset="windows-1252" or iso-8859-1 or ANSI or ansi. I also tried to change the charset directly in the JS code :+1: ... var charset = scope.charset || "windows-1252"; ... everywhere utf-8 was present, but at the end, it seems to not use the given charset, using all the time the UTF-8. Is there something to do previously to specify the charset?

Thanks

IvanCoronado commented 8 years ago

Charset is working properly but you cannot force the browser to send you data in a given encoding, the charset is just "suggesting" the format but the browser is always returning UTF-8. So you can't get this done in client side, you need send the file to the server. More info