gpt4 book ai didi

MySQL 在 UTF-8 表中搜索 "äåö"没有找到任何内容

转载 作者:行者123 更新时间:2023-11-30 00:47:08 25 4
gpt4 key购买 nike

数据显示正确,但在搜索时找不到任何内容。这就是数据以 UTF8 编码存储在表中的方式。

Default charset: utf8mb4
names: utf8
character_set_client : utf8

enter image description here

SELECT * FROM article WHERE description like '%några%' //returns null but it should return one row
SELECT * FROM article WHERE description like '%nå%' //works
SELECT * FROM article WHERE description like '%någ%' //returns null

我认为 mysql 将 å 转换为 a。

我尝试使用 php 函数 utf8_encode($str) 将搜索查询转换为 utf8。但这里没有成功。我该如何解决这个问题?

最佳答案

"nÃ¥gra" stored in the database and "några" are obviously not the same words. You have an encoding problem when inserting into the database, storing your data as garbage. – deceze 15 mins ago

"några" encoded in UTF-8 will display as "några" when interpreted as UTF-8. "några" encoded in Latin-1 will display as "några" when interpreted as Latin1. A string misinterpreted or misconverted at some point will look like garbage. – deceze 2 mins ago

duplicate of UTF-8 all the way through – deceze 16 mins ago

关于MySQL 在 UTF-8 表中搜索 "äåö"没有找到任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21277361/

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