0

Hy there

I have a weird effect when a *.csv file is parsed. I debugged the process and I saw, that there is a problem with the german "Umlaute" when loading the csv file. When I load the file from my dropbox account everything is correct. When I load the file form my pc, then the german "Umlaute" are not correct and so the parsing of the file is incorrect.

e.x.:

csv File: Graubünden;in Betrieb

when loading the data from my pc: Graub�in Betrieb

so, when the file is loaded, there is no ';' and the data can't be split correctly.

Why is this? I saw here that adding the UFT-8 BOM could solve the problem. But I don't know how to do this, and yes, I've already searched on Google.

Here's the code:

jQuery.get('resource/myFile.csv', function (data) { ... }

thanks Guys

Community
  • 1
  • 1
reneton
  • 61
  • 9

2 Answers2

1

What is the encoding of the file? Assuming byte-oriented: If UTF-8 then the character is 2 bytes. If ISO-8859-1 (also known as Latin-1) then the character is only 1 byte. Those are the two most likely byte-oriented encodings, though not the only ones.

No matter: You must know the file's encoding, and then know your language's string encoding. There are several ways to do this, but all require that you are aware of the encoding.

I have seen tools that cause confusion. For example, my Linux shell is UTF-8 encoded. But if I load an ISO-8859-1 encoded file and then save it, GNU Emacs reads it correctly and coverts it to UTF-8, changing the encoding out from under me and causing me to think my Latin-1 converter was broken.

A hex editor (bvi is one of many) is invaluable for helping track down these types of issues.

Brian Yoder
  • 186
  • 6
  • What I don't understand is, why it works correctly, when I load the file from dropbox, but it is wrong enconded when I load it form my pc? – reneton Apr 14 '14 at 18:27
  • It works when the encoding is what your jQuery expects. Depending on how you access Dropbox, the client may be converting the file's encoding. Search for "jQuery encoding" and you should find many specific answers. – Brian Yoder Apr 14 '14 at 18:40
0

Why is this? I saw here that adding the UFT-8 BOM could solve the problem. But I don't know how to do this, and yes, I've already searched on Google.

Use notepad++ and go [Encoding] (could be called diferently, in german it's "Kodierung") and hit "Convert to UTF-8" for UTF-8 with BOM or "Convert to UTF-8 without BOM".

I don't know if that will solve your problem though.

Ch33f
  • 609
  • 8
  • 17
  • Thanks for your answer. I want to use the *.csv file as it is and if necessary do the conversions in js. I just opened the csv file with Notepad++ and set the encoding to UTF-8 and UTF-8 without BOM. But it Looks the same – reneton Apr 14 '14 at 18:14
  • If I use for Encoding ANSI in Notepad++ everything is displayed correctly – reneton Apr 14 '14 at 18:24