A problem with passing Japanese characters(UTF-8) via json_encode

前端 未结 1 1010
情书的邮戳
情书的邮戳 2021-01-16 10:53

I\'m having a trouble transferring Japanese characters from PHP to JavaScript via json_encode.

Here is the raw data read from csv file.

PRODUCT1,QA,         


        
相关标签:
1条回答
  • 2021-01-16 11:07

    I found that the problem was PHP fgetcsv() function not being able to recognize the characters in EUC-JP. Apparently, fgetcsv() uses the system locale setting to make assumptions about character encoding. I have added below line before doing fgetcsv() as the referenced example shows(but in a reversed way), and it fixed the problem!

    setlocale(LC_ALL, 'ja_JP.EUC-JP'); 
    
    0 讨论(0)
提交回复
热议问题