I have a .csv
file. I grab the file using jQuery.get()
.
$.get("data.csv", function(data) {
console.log(data)
}, "text")
Later I want to save the file in an xml.
Now my problem is the datatype of my text.
What I have Å, ë, ö, etc.
What I output �, �, �, �
How can I get the correct format of the text from a .csv file into javascript?
Edit
My meta charset is OK: <meta charset="utf-8">
But notice that I don't display the output of the csv file, I just add some more info and save it in an xml.
When I console.log the output I see these � chars. The same when I save it in the xml. But in my csv file I have the correct char.
Edit 2
I just found this awesome tool. It is in AS3.
When I insert Å ë ö
I need the output of escape()
.
When I use javascript.escape() for Å
I get weird chars like %uFFFD
instead of %C5
so I guess my script tries to escape �
to %uFFFD
Solution
Here the solution for people who have the same problem.
$.ajaxSetup({
'beforeSend' : function(xhr) {
xhr.overrideMimeType('text/html; charset=iso-8859-1');
}
})
$.get("data.csv", function(data) {
console.log(data)
}, "text")