使用 JSON 和一些特殊字符时最好的排序规则是什么

What is the best collation when using JSON and some special characters

我正在尝试使用 php 和 JSON 从 mysql 数据库获取数据,但由于我选择的排序规则,它无法正常工作。 我正在使用这些字符:® ,é, è , ™, É 我在 mysql 中的默认排序规则是:latin1_swedish_ci,我的服务器默认排序规则是:utf8mb4_unicode_ci。 我应该只删除那些特殊字符还是什么? 这是 php 代码:

<?php 
require "conn.php";
$sql = "select * from produit";
$result = mysqli_query($conn, $sql); // result contient tous les produits 
$response = array(); // on déclare un array
// pour chaque ligne de la table 
while ($row = mysqli_fetch_array($result)) { 
array_push($response, array("id_produit"=>$row[0] , "nom"=>$row[1], "catégorie"=>$row[2], "description"=>$row[3], "type"=>$row[4], "prix"=>$row[5], "qte_stock"=>$row[6]));
}
echo json_encode(array("server_response"=> $response));
mysqli_close($conn);

 ?>

显示创建 table 产品:

CREATE TABLE `produit` (
 `id_produit` int(11) NOT NULL AUTO_INCREMENT,
 `nom` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
 `catégorie` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
 `description` text COLLATE utf8mb4_unicode_520_ci NOT NULL,
 `type` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
 `prix` int(11) DEFAULT NULL,
 `qte_stock` int(11) DEFAULT NULL,
 PRIMARY KEY (`id_produit`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci

对于所有想知道如何解决法语字符问题的人 JSON 相信我,这些天我已经尝试了所有方法,唯一有效的是:

echo json_encode(array("server_response"=>$response), JSON_UNESCAPED_UNICODE);

这里是 link 了解更多信息 http://php.net/manual/fr/function.json-encode.php 感谢上帝,我一度失去了希望