-1
在數據庫中,我在utf8_general_ci中設置了一列,並用於放置一些中文單詞。我可以用「香港」這種方式看到這些單詞,但是當我通過php選擇數據並回顯單詞時,它們變成了這個「\ u9999 \ u2f2f」。那麼我怎樣才能得到像「香港」這樣真正的中文詞彙。在php中將utf8更改爲中文單詞
<?php
include 'dbconfig.php'; //search queue by uid, display json
$link = mysql_connect($host, $uname, $pass) or
die("Database connection failed!");
mysql_select_db($database, $link) or
die("Database could not be selected!");
$keyword = $_POST['keyword'];
$query = "SELECT qid, qname, description FROM queuing WHERE setUpUid = '".$keyword."' AND isValid = true";
$result = mysql_query($query) or die("Fail");;
$cart = array();
while($array = mysql_fetch_array($result)){
$cart[] = array(
"qid" => $array['qid'],
"qname" => $array['qname'],
"description" => $array['description']
);
}
echo json_encode(array("response"=>$cart));
mysql_close($link);
?>
輸出繼電器:{"response":[{"qid":"6","qname":"\u9999\u6e2f","description":"\u9999\u6e2f"}]}
http://stackoverflow.com/questions/279170/utf-8-all-the-way-through [PDO查詢 – Mihai
可能重複返回很多,我不能轉換爲Unicode爲\ uXXXX字符代碼字符(http://stackoverflow.com/questions/16583954/pdo-query-returns-lots-of-uxxxx-character-codes-which-i-cant-convert-to-unicod) – deceze