-1

Helo I have a problem with diacritics .. in Mysql it's fine i set the utf8_general_ci you cand see in this picture enter image description here

in my website it's fine you can see

enter image description here

But when i export to csv file don't work.. Another file with diacritic reads my excel but this not.

enter image description here

I use this code for export

function doCsv(){

    var table = document.getElementById("exportTable").innerHTML;
    var data = table.replace(/<thead>/g,'').replace(/<\/thead>/g,'')
    .replace(/<tbody>/g,'').replace(/<\/tbody>/g,'')
    .replace(/<tr role="row" class="odd">/g,'').replace(/<tr role="row" class="even">/g,'').replace(/<\/tr>/g,'\r\n')
    .replace(/<th style="background-color:#6699ff;">/g,'').replace(/<\/th>/g,';')
    .replace(/<td>/g,'').replace(/<\/td>/g,';')
    .replace(/\t/g,'').replace(/\n/g,'');
    var link = document.createElement('a');
    link.download = "exportToCSV.csv";
    link.href = "data:application/csv," + escape(data);
    link.click();

And if i put the alert it keeps well see :

enter image description here

Anyone to help me?

O. Jones
  • 103,626
  • 17
  • 118
  • 172

1 Answers1

0

See the %u0218? That means that something is converting to Unicode. You don't want that. You want utf8 (or utf8mb4).

Select the HEX from the table. For these letters: ĂÎŞŢÂ, you should get this hex if it is properly encoded in UTF-8: C482 C38E C59E C5A2 C382. Note that each accented letter turns into 2 hex bytes.

Your second attempt came back with ĂÎŞŢÂ, which is "Mojibake" for ĂÎŞŢÂ. It's hex is C384E2809AC383C5BDC385C5BEC385C2A2C383E2809A.

I discuss Mojibake and point out what was done wrong in Trouble with UTF-8 characters; what I see is not what I stored .

Somehow, your Excel code needs to say to export UTF-8, not unicode.

And your table must be utf8, not latin1.

And the import must declare that the data is utf8.

Rick James
  • 135,179
  • 13
  • 127
  • 222