中文字符问题,PHP webservice

时间:2013-08-30 11:21:29

标签: php mysql web-services utf-8

我正在调用一个在php中开发的web服务。当我选择中文时,WS的反应不正确。对于其他语言来说,这很好,但对于中国人的行为是不正常的。

WS的输出是

{

    "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"
            }
        ]
    }

}  

我希望"question":"我们可以得到我们的家庭会议?"代替"question": "??????????????",

请帮我解决这个问题。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

试试这个简单的代码:

修改

    $str1 = base64_encode("我们可以得到我们的家庭会议?");
    $str2 = base64_decode($str1);
    echo $str2;

这给出了角色。因此,在将数据发送到Web服务(来自数据库)进行问题编码时,再次对其进行解码。因为问题在于这些字符的编码。