Values in UTF-8 being encoded as NULL in JSON

后端 未结 5 2049
鱼传尺愫
鱼传尺愫 2021-02-08 19:39

I have a set of keywords that are passed through via JSON from a DB (encoded UTF-8), some of which may have special characters like é, è, ç, etc. This is used as part of an auto

5条回答
  •  长情又很酷
    2021-02-08 20:34

    I tried your code sample like this

    [~]> cat utf.php 
     php utf.php 
    ["Coffee","Cappuccino","Caf\u00e9"]
    [~]>
    

    Based on that I would say that if the source data is really UTF-8, then json_encode works just fine. If its not, then thats where you get null. Why its not, I cannot tell based on this information.

提交回复
热议问题