How to json_encode array with french accents?

后端 未结 7 2292
离开以前
离开以前 2020-12-05 13:58

I have an array item with a French accent ([WIPDescription] => Recette Soupe à lOignon Sans Boeuf US). The data is being properly pulled from the database (mysql).

相关标签:
7条回答
  • 2020-12-05 14:27

    If you deal with diacritics you can also add JSON_PARTIAL_OUTPUT_ON_ERROR and it will remove only the problems and leave the rest intact. I used utf_encode before I found this but it was messing up diacritics.

    echo json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR);
    
    0 讨论(0)
提交回复
热议问题