开发者

how should utf8_general_ci data be stored?

i'm using utf8_general_ci, how should data be stored?

i mean like if i have a varchar/text that contains special chars like áéíóúàèìòùçÇÀ开发者_开发问答ÉÌÒ, they are stored like that or they are converted in some way? im making a CASE/ACCENT INSENSITIVE search, but people told me i wasnt properply storing data, so i need a reference

so confused about this, even my ORDER BY is not working because the data is broken (after i know how data should be store im going to convert my database, the tables/setnames are already utf8_general_ci / utf8)


i'm using utf8_general_ci, how should data be stored?

Just store it properly. :)

Seriously: You should store it so that, when you view the UTF-8 encoded database through an UTF-8 encoded connection in a program like phpMyAdmin or HeidiSQL, you see the actual characters áéíóúàèìòùçÇÀÉÌÒ. Nothing more to it.

utf8_general_ci is already accent insensitive in that

 á = a
 é = e

if you use a LIKE clause columnname LIKE "searchterm" instead of columnname = "searchterm", it will also be case insensitive.


Are you sure the data is broken? When you retrieve it from the table, are all the accents missing? UTF-8 is a character set, utf8_general_ci is a collation. They're are different. If you want your ORDER BY to truly sort correctly, you may want to use utf8_unicode_ci instead. Collation is mainly in reference to searching and sorting, not storing.

Can you post your SHOW CREATE TABLE result?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜