Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top