汉字问题,PHP Web服务
我正在调用一个用php开发的Web服务。当我选择中文时,WS的响应不正确。对于其他语言来说,它很好,但对于中国人来说,它的行为是不正常的 WS的输出是汉字问题,PHP Web服务,php,mysql,web-services,utf-8,Php,Mysql,Web Services,Utf 8,我正在调用一个用php开发的Web服务。当我选择中文时,WS的响应不正确。对于其他语言来说,它很好,但对于中国人来说,它的行为是不正常的 WS的输出是 { "response": { "@attributes": { "error": 0 }, "code": 200, "message": "success", "data": [ {
{
"response": {
"@attributes": {
"error": 0
},
"code": 200,
"message": "success",
"data": [
{
"faq_id": "4",
"app_id": "7",
"question": "What is the main goal for the conference?",
"answer": "This conference is designed to review our Q3 achievements and plan our Q4 goals",
"status": "1"
},
{
"faq_id": "5",
"app_id": "7",
"question": "??????????????",
"answer": "This is strictly an employee only conference.",
"status": "1"
},
{
"faq_id": "6",
"app_id": "7",
"question": "Where do we stay for the conference?",
"answer": "Details on accomodations will be provided to you before the conference begins",
"status": "1"
}
]
}
}
我期待着“问题”:我们可以得到我们的家庭会议?"代码>而不是“问题”:“???????”,
请帮我解决这个问题。
提前感谢。尝试以下简单代码:
编辑
$str1 = base64_encode("我们可以得到我们的家庭会议?");
$str2 = base64_decode($str1);
echo $str2;
这将使字符保持原样。因此,在将数据发送到web服务(从数据库)时对于问题,请将其编码并再次解码。因为问题在于这些字符的编码。可能是web服务在与数据库交互时没有设置正确的编码。如果您可以控制其代码,请在此处显示。如果没有,我们无法在客户端执行任何操作。