gpt4 book ai didi

php - 将文件导入 mysql 数据库导致口音错误

转载 作者:行者123 更新时间:2023-11-30 22:50:14 24 4
gpt4 key购买 nike

我有一个包含类似内容的 utf8 json 文件:

"type":"Feature","geometry":{"type":"LineString","coordinates":[[-73.6371999890417,45.451049968774],[-73.6362864025022,45.4507004803266]]},"properties":{"FIN_GCH":191,"TYP_VOIE":"avenue","LIM_GCH":"Montréal-Ouest","NOM_VOIE":"Brock","CLASSE":0,"DEB_DRT":0,"FIN_DRT":0,"LIM_DRT":"Montréal-Ouest","LIE_VOIE":"","DEB_GCH":173,"ID_TRC":1602102,"DIR_VOIE":"Sud","SENS_CIR":-1}}
,{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-73.6382813452807,45.4514760942107],[-73.6371999890417,45.451049968774]]},"properties":{"FIN_GCH":171,"TYP_VOIE":"avenue","LIM_GCH":"Montréal-Ouest","NOM_VOIE":"Brock","CLASSE":0,"DEB_DRT":150,"FIN_DRT":152,"LIM_DRT":"Montréal-Ouest","LIE_VOIE":"","DEB_GCH":143,"ID_TRC":1602103,"DIR_VOIE":"Sud","SENS_CIR":-1}}

在 php 脚本的帮助下,我将所有数据放入 mysql UTF8 数据库中,但即便如此,条目仍有奇怪的口音:我使用的不是 Montréal-Ouest,而是 Montréal-Ouest

你知道问题出在哪里吗?

谢谢

最佳答案

我必须通过像这样设置选项数组来设置与服务器的 utf8 连接

$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
);

$connection = new PDO( $dns, $user, $password, $options );

感谢 CBroe

关于php - 将文件导入 mysql 数据库导致口音错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28377734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com