Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode UTF-8 in CSV #1410

Closed
nato90 opened this issue Jun 16, 2017 · 11 comments
Closed

Encode UTF-8 in CSV #1410

nato90 opened this issue Jun 16, 2017 · 11 comments

Comments

@nato90
Copy link

nato90 commented Jun 16, 2017

As you can encode in UTF-8 when exporting in cvs?, since the accents shows them like this:

Dirección -> Dirección

@rbasurto
Copy link

It must be the lack of the BOM Header (https://en.wikipedia.org/wiki/Byte_order_mark).

@masahtak
Copy link

masahtak commented Jun 20, 2017

77 var exportCSV = function exportCSV(data, keys, filename) {
78 var dataString = toString(data, keys);
79 if (typeof window !== 'undefined') {
80 saveAs(new Blob([dataString], { type: 'text/plain;charset=utf-8' }), filename, true);<--- true|false
81 }
82 };

I have same ploblem.
I want to add an option to change(true|false) no_auto_bom argument in FileSaver.js's saveAs func, or more good solution.

@AllenFang
Copy link
Owner

@masahtak, could you confirm that we only change the bool value for last argument can solve this issue? If yes, I can make it configurable :)

saveAs(new Blob([dataString], { type: 'text/plain;charset=utf-8' }), filename, true)

@nato90
Copy link
Author

nato90 commented Jun 20, 2017

@AllenFang @masahtak If it works! Thank you, just change the last parameter to false:

saveAs(new Blob([dataString], { type: 'text/plain;charset=utf-8' }), filename, false)

@rbasurto
Copy link

I think it would be better if it's configurable.

@masahtak
Copy link

@AllenFang yes I can solve this issue if it's configurable!

@AllenFang
Copy link
Owner

Sounds great, I'll fix it in next version, thanks

AllenFang added a commit that referenced this issue Jul 4, 2017
@AllenFang
Copy link
Owner

Hi all, it was fixed on v3.4.3, now you can assign options.noAutoBOM to false to disable BOM Header

@masahtak
Copy link

thx AllenFang! but noAutoBOM option looks like doesn't work...

1076 exportCSVUtil(result, keys, csvFileName, separator, noAutoBOM || true);

noAutoBOM || true -> "true" only

@AllenFang
Copy link
Owner

@masahtak, fxck,,,,, I forgot it was a bool value,,,, let me patch again in next version lol

@AllenFang
Copy link
Owner

@masahtak fixed again and release on v3.4.5, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants