来自twitter API的JSON包含\ u2019

Ale*_*and 4 php mysql twitter json

这是我通过twitter API获取的JSON文件的一部分:

"文字":"科学家发现研究分子的新方法:女王研究人员已经发现了研究方法...... http://bit.ly/chbweE "

我正在为我的项目使用PHP.

在使用json_decode函数之后,\ u2019被转换为',这基本上非常烦人.

我尝试使用$raw_json = preg_replace("u2019","'",$raw_json),但然后该json_decode函数返回NULL.

有没有其他方法可以将\ u2019转换成'?

谢谢


编辑:

这就是我获取JSON的方式:

// create curl resource
    $ch = curl_init();

    // set url
    curl_setopt($ch, CURLOPT_URL, "http://search.twitter.com/search.json?q=from%3Agizmodo&rpp=10");

    //return the transfer as a string
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // $output contains the output string
    $raw_json = curl_exec($ch);

    // close curl resource to free up system resources
    curl_close($ch);
Run Code Online (Sandbox Code Playgroud)

Sea*_*ean 6

这可能是您在输出中使用的字符集的问题.如果您要输出到HTML页面,请尝试将以下元标记添加到您的头部:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Run Code Online (Sandbox Code Playgroud)