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

Microsoft Excel 2010 doesn't render file with charset UTF-8 #51

Open
imjayson opened this issue Aug 21, 2014 · 11 comments
Open

Microsoft Excel 2010 doesn't render file with charset UTF-8 #51

imjayson opened this issue Aug 21, 2014 · 11 comments

Comments

@imjayson
Copy link

There is a bug in MS Excel where it doesn't honor the charset specified in the CSV file without a Byte Order Mark (BOM).

image

The fix is as such:
var BOM = "%ef%bb%bf";
var DATA_URI_PREFIX = "data:text/csv;charset=utf-8," + BOM;

I'd love to submit a pull request but I am unable setup the dev env to run the existing tests.

@tvanro
Copy link

tvanro commented Sep 19, 2014

Thank you for the fix, it worked like expected.
This should defiantly be included in the next release!

@jkarttunen
Copy link

Might this be the reason for rendering öäå with similar artifacts? (Excel for Mac 2011)

@imjayson
Copy link
Author

imjayson commented Oct 7, 2014

i would think so. give it a shot.

@alidavut
Copy link

alidavut commented Oct 9, 2014

+1

@eitetsujo
Copy link

With ng-csv.min.js, a BOM is not prepended.
It goes well with ng-csv.js.
It looks like a problem related with uglifying.

@eirikb
Copy link

eirikb commented Aug 27, 2015

@eitetsujo did you try to add add-bom="U+FEFF"?

@Mavlarn
Copy link

Mavlarn commented Jul 18, 2016

It can not work for me.
The file ng-csv.min.js is included as defined in package.json. And in my app, all vender js files are compressed as a single file. In this case, the BOM char '\ufeff' is replaced as empty char.
If I add ng-csv.js by myself, the after compression, the BOM char is still right. So as most of the js libs do, the NOT min version file should be the main js.

@Mavlarn
Copy link

Mavlarn commented Jul 18, 2016

Another problem about the add-bom is, if I set add-bom="true" as that in example, the attribute true will be evaluated as string, but not boolean, so even add-bom="false" will be trated as enabling BOM.

@eirikb
Copy link

eirikb commented Jul 18, 2016

@Mavlarn
Are you sure it's replaced with an empty char, and not the actual BOM char?
E.g., if you run '\ufeff' in your console it will look empty, but it's there.
You could perhaps even copy/paste this code into your console to see what I mean:

encodeURIComponent('')

That aside I don't understand why export to Excel isn't just a default UTF16 + delimiter, wouldn't that just always work?

@Mavlarn
Copy link

Mavlarn commented Jul 18, 2016

If I compress min version, encodeURIComponent(b) display empty char, but the NOT min version, result is "%EF%BB%BF"

@eirikb
Copy link

eirikb commented Jul 18, 2016

@Mavlarn You are correct. The minified file does have the correct char, but after running it through uglifyjs (version 2.4.10) the char is removed.

screenshot from 2016-07-18 13-51-41

Update: Should have used uglify-js, not uglifyjs.
After using uglify-js it looks like this: c="\ufeff"

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

No branches or pull requests

7 participants