我正在尝试用希伯来语打印 JSON 并且只获得 utf-8 编码的字符串。如何确保客户端的浏览器以希伯来语显示字符串?
代码是:
<html>
<head>
<meta charset=utf-8" />
</head>
<body>
<?php
header('Content-Type: text/html; charset=utf-8');
$response = array();
require_once __DIR__.'/db_connect.php';
$db = new DB_CONNECT();
$result = mysql_query(" SELECT * FROM stores") or die(mysql_error());
if (mysql_num_rows($result)>0){
$response["stores"]=array();
while($row = mysql_fetch_array($result)){
$store = array();
$store["_id"]=$row["_id"];
$store["name"]=$row["name"];
$store["store_type"]=$row["store_type"];
array_push($response["stores"],$store);
}
$response["success"] = 1;
$string = utf8_encode(json_encode($response));
echo hebrevc($string);
}else{
$response["success"]=0;
$response["message"]="No stores found";
echo utf8_encode(json_encode($response));
}
?>
</body>
</html>
回应是:
{{"商店":[{"_id":"1","名称":"\u05d7\u05ea\u05d5\u05dc\u05d9","store_type":"\u05de\u05e1\u05e2\u05d3\u05ea \u05d1 \u05e9\u05e8\u05d9\u05dd"},{"_id":"2","name":"\u05de\u05e2\u05d3\u05e0\u05d9 \u05de\u05d0\u05de\u05d9","store_type":" \u05de\u05e1\u05e2\u05d3\u05d4 \u05dc\u05e8\u05d5\u05e1\u05d9\u05dd"}],"成功":1