我的网页包含来自数据库的数据的JSON代码,代码由PHP脚本生成,但是JSON代替显示那些“čšćđž”的内容显示类似“\ u0161”,“\ u0111”等,但是我无法弄清楚我错在哪里,编码表,数据库,文档,标题是UTF-8
这是指向页面http://dmb.site50.net/application.php?app_access_key=c4ca4238a0b923820dcc509a6f75849b
的链接这是PHP脚本的源代码
$APP_URL_ACCESS = $_GET['app_access_key'];
$sql_app = mysql_query("SELECT * FROM app_sys WHERE APP_OW_C='$APP_URL_ACCESS'") or die(mysql_error());
if(mysql_num_rows($sql_app)==1){
while($row = mysql_fetch_array($sql_app)){
$APP_UA_ID = $row['APP_UA_ID'];
$APP_NM = $row['APP_NM'];
$APP_H_DMN = $row['APP_H_DMN'];
$APP_H = $row['APP_H'];
$APP_H_DB_UNM = $row['APP_H_DB_UNM'];
$APP_DB_NM = $row['APP_DB_NM'];
$APP_H_DB_PSW = $row['APP_H_DB_PSW'];
$APP_H_DB_SRV = $row['APP_H_DB_SRV'];
$APP_ACTIVE = $row['APP_ACTIVE'];
$APP_OW_C = $row['APP_OW_C'];
}
$ROW_APP[] = array(
'APP_UA_ID' => $APP_UA_ID,
'APP_PERMISSION' => $APP_ACTIVE,
'APP_KEY' => $APP_OW_C);
$APP_ARRAY[] = $ROW_APP;
($APP_ACTIVE == '1')? $sql_connect_app = mysql_connect($APP_H_DB_SRV, $APP_H_DB_UNM, $APP_H_DB_PSW) && mysql_select_db($APP_DB_NM): $_MSG = "Application Is Not Active";
$sql_news = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 10") or die(mysql_error());
while($row = mysql_fetch_array($sql_news, MYSQL_ASSOC)){
//$display_json['data'] = array(
//'id' => $row['id'],
// 'title' => $row['title'],
// 'story' => $row['story'],
// 'img' => $row['img'],
// 'author' => $row['author'],
//'datetime' => $row['datetime'],
//'shorten_story' => substr($row['story'], 0, 150) . '...'); */
$ROW_APP_DATA[] = $row;
//
}
$sql_news = mysql_query("SELECT * FROM actual ORDER BY id DESC LIMIT 10") or die(mysql_error());
while($row = mysql_fetch_array($sql_news, MYSQL_ASSOC)){
/*$display_json['data'] = array(
'id' => $row['id'],
'title' => $row['title'],
'story' => $row['story'],
'img' => $row['img'],
'author' => $row['author'],
'datetime' => $row['datetime'],
'shorten_story' => substr($row['story'], 0, 150) . '...'); */
$ROW_APP_THIRDPART[] = $row;
//
}
$JSON_ARRAY_APP['application'] = $ROW_APP;
$JSON_ARRAY_DATA_1['news'] = $ROW_APP_DATA;
$JSON_ARRAY_DATA_2['actual'] = $ROW_APP_THIRDPART;
$JSON_ARRAY_DATA['data'] = array_merge($JSON_ARRAY_DATA_1, $JSON_ARRAY_DATA_2);
$JSON_OUTPUT = array_merge($JSON_ARRAY_APP, $JSON_ARRAY_DATA);
echo json_encode($JSON_OUTPUT);
}else{
exit();
}
答案 0 :(得分:5)
这是正常的。 JSON的规范使用\uxxxx
序列来扩展unicode字符。请参阅http://json.org并搜索“unicode”。
JSON字符串通常不适合人类使用,因此字符在其中的编码方式并不重要。如果您的消费者正确支持unicode,那么当您将json字符串解码回原生数据结构时,您将获得原始重音字符。