我正在用 json 编码一些文本:
$json = array('result' => '',);
$json['result'].='My name is Roger';
echo json_encode($json);
我的输出是My name is Roger
.
但是当我写
$json = array('result' => '',);
$json['result'].='test {#[^[*]+|€~!,<€¥<=?"{*\>Ö.ßäülenwj test ';
echo json_encode($json);
然后我没有得到任何输出。
我也测试过,htmlspecialchars
但没有成功。
也许您的文件是 ISO-8859-1/15 编码的。json_encode 仅适用于 utf8 字符集。
在您的测试场景中,您可以将整个文件转换为 utf8,我认为您会得到正确的响应。
否则,您需要使用 utf8_encode("iso_string"); 将字符串转换为 utf8;
希望这可以帮助。
达斯汀
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句