法语重音字符解码以进行 SQL 匹配
我在匹配法语重音字符时遇到问题(请注意,还将使用其他不同的字符,例如中文、日文)。
当我输入将检查数据库的法国街道名称时,我遇到了错误:
Incorrect string value: '\xE2teau' for column 'street_name' at row 1
对于此名称中的此字符:
Le Château
我已将我的列更改为 utf8_general_ci
并且它仍然向我抛出那个错误。如何“解码”它们以与列匹配?
I'm having a problem with matching against french accented characters (note that other different characters such as chinese, japanese will also be used).
I've ran across an error when I input a french street name that will check the database and I had an error:
Incorrect string value: '\xE2teau' for column 'street_name' at row 1
For this character in this name:
Le Château
I've changed my column to utf8_general_ci
and it still throws me that error. How can you "decode" them to match against a column?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您实际上是在发送 UTF-8 数据,还是在发送 Latin-1 编码数据? MySQL 可能会因
âte
阻塞,因为â
正在作为字节E2
传输,并且它期望接下来出现一个具有合适值的字节,但是看到的是t
的74
。因此该字符串不是有效的 UTF-8。在创建查询之前尝试对字符串值使用
utf8_encode()
?Are you actually sending UTF-8 data, or are you sending Latin-1 encoded data? MySQL may be choking on
âte
becauseâ
is being transmitted as the byteE2
and it expects a byte with a suitable value to come next, but sees the74
fort
instead. Thus the string is not valid UTF-8.Try using
utf8_encode()
on the string value before creating the query?