为什么 PHP 脚本显示 /uXXXX 字符而不是希腊字符,即使我更改了字符集?

Why PHP script displaying /uXXXX characters instead of greek characters evenif I change character set?

我有以下代码:

/* change character set to utf8 */    
if (!mysqli_set_charset($con, "utf8")) 

{

printf("Error loading character set utf8: %s\n", mysqli_error($con));

} else {

printf("Current character set: %s\n", mysqli_character_set_name($con));

}

// query the application data
$sql = "SELECT * FROM names";

$result = mysqli_query($con, $sql);

// an array to save the application data
$rows = array();

// iterate to query result and add every rows into array
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) 
{

$rows[] = $row;
}


// close the database connection
mysqli_close($con);

// echo the application data in json format
echo json_encode($rows);

我在服务器 http://blabla.gr/apps.php 上试了一下,我得到了 \u0391\u03bd\u03c4\u03ce\u03bd\u03b7\u03c2 而不是希腊字符

如何让它们正确显示为普通的 utf8 希腊字符。

json_encode function encodes Unicode characters using escape codes by default. You can use the JSON_UNESCAPED_UNICODE 标记使它们不被转义。

echo json_encode($rows, JSON_UNESCAPED_UNICODE);