1

I have an CSV file with city names stored, some of these city name contain special charactors such as "São Paulo".

I use an AJAX call to access the CSV as follows:

$.ajax({
    url: 'LIST-char2.csv',
    dataType: "html",
    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
    success: function(data){
        alert(data)
    }
}); 

Alerted data returns the "?" symbol for the "ã" charactor.

I've tried saving the CSV as UTF-8 in Excel and setting the page meta tag to charset=UTF-8.

Any help greatly appeciated

blacktea
  • 142
  • 1
  • 2
  • 12

1 Answers1

0

NOTE: I tried saving in Excel as UTF-8, this didnt appear to actually convert the file to UTF-8

I Fixed this by opening the CSV file in notepad++ and using "Convert to UTF-8", I then ensured my page was using UTF-8 by including a meta tag:

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

and setting "scriptCharset" on my AJAX call:

$.ajax({
          url: 'list-UTF.csv',
          dataType: "html",
          scriptCharset: "UTF-8",
          success: function(data){
                var rows = data.split("\n");
                rows.shift();
                ticker(rows)
          }
        });
blacktea
  • 142
  • 1
  • 2
  • 12