esvit / ng-table-export

Export data from ngTable to CSV
BSD 3-Clause "New" or "Revised" License
44 stars 95 forks source link

ng-table export encoding to utf-8 hebrew letters #16

Open ihabassi opened 9 years ago

ihabassi commented 9 years ago

Hi, I tried to export to a csv file using the ng table export. I need the hebrew letters but till didn't get a hebrew letter.

Can you help me with that?

Thanks

thiagodp commented 9 years ago

It appears that the library isn't exporting to UTF-8 correctly. Even using other languages - actually, other formats, such as latin-1 - we get the same problem.

The file is being exported to ANSI (you can see it using a hex editor, for example) instead of UTF.

Maybe it should using XRegExp (http://xregexp.com/) or some other lib, in order to support unicode RegEx...

@update: As pointed out by @davisford the problem is with the viewers, not with the file format.

davisford commented 9 years ago

AFAIK, a string in the DOM is UTF, and the plugin is doing nothing more than copying those strings into a big JS string. It's questionable whether JavaScript is UTF-16 or UCS-2...I guess it varies, but either way it shouldn't convert these to ASCII. Are you certain that whatever editor you are using to view them isn't changing the encoding or representation?

Why not try dumping the contents of the plugin's export string instead to the console and see if it still matches what you see in the DOM.

thiagodp commented 9 years ago

I thought that the regex filter would return an ANSI string, since it doesn't offer UTF support (e.g. "/u"). Actually, the output format is not changed.

I checked the content with these free/opensource hex editors: FreeHexEditor, Frhed, HexEdit, wxHexEditor, and Mh-Nexus. Surprisingly, none of them have proper UTF support (except for the paid version of the first one). Microsoft Excel has the same problem. It tries to show the file using ANSI (I couldn't find any option to change that). Just with a paid editor in trial version I could check the format. So, the problem was really with the editors I had used. This could possibly answer @ihabassi's question.

@davisford +1

floydpink commented 9 years ago

Since this repo was not being updated, we forked it and would welcome suggestions like these that could improve the library.

Check out https://github.com/kollavarsham/ng-table-to-csv

zejli commented 9 years ago

Have you fixed the problem with the ngtableExport to csv? I have ANSI encoding instead of utf8.What should I do ?

thiagodp commented 9 years ago

@zejli I recommend you to check your file viewer. Probably it is not opening the file in UTF-8 but in ASCII (see my comments above).

zejli commented 9 years ago

Yes I know this is the problem.How can I fix it please!

osde commented 9 years ago

While openin with Open Office Calc it asks in which encoding to open, if you choose UTF-8 problem will be solved