json_encode与utf8的问题 [英] json_encode problems with utf8

查看:128
本文介绍了json_encode与utf8的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL数据库与一些表,全部编码在utf8_general_ci。
我正在请求mysqli并返回一个数组。



如果我执行 print_r($ my_db_answer); 我得到åäö工作像

 数组

[hi] => hej
[hello] =>hallå

如果我做 echo json_encode($ my_db_answer); 我得到所有不包含åäö的字符串在包含这些值的字符串上正确和为null,如下所示:

  {hi:hej,hello:hall\\\å} 

关于php手册json_encode只适用于utf8,那么这里有什么问题?

解决方案

没关系...



(在我解码json之前,我在客户端中che住了json)


Im having a MySQL db with some tables, all encoded in utf8_general_ci. I'm requesting with mysqli and returns an array.

If i do print_r($my_db_answer); i get åäö working like

Array
(
    [hi] => hej
    [hello] => hallå
)

if i do echo json_encode($my_db_answer); i get all the strings not containing åäö correct and null on the strings containing these values, like this:

{"hi":"hej","hello":"hall\u00e5"}

Regarding to php manual json_encode only works with utf8, so what's the problem here?

解决方案

Never mind...

(I was cheking the json in the client before i decoded the json)

这篇关于json_encode与utf8的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆