mysql utf8 character problem

I set all character set as "utf8" in pages, I set all collation (also fields collation) as utf8_general_ci in database, and I add this code in connect.php

mysql_set_charset('utf8',$connect);
mysql_query("SET NAMES 'utf8'");

Although everything is utf, when i run this query:

"SELECT * FROM titles WHERE title='toruń'"

Result: it returns " toruń " and " torun " which's are different words.

So what do you think?
What is the problem?

Thanks!

EDIT:

CREATE TABLE IF NOT EXISTS titles
(
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL,
PRIMARY KEY ( id ),
KEY title ( title ),

) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=37 ;


The problem is that the collation you have chosen is designed to ignore that particular accent (and, most likely, accents in general).

If you expect to be storing a particular language, rather than a number of different languages, try using utf8_(language)_ci (if that language is not present, there might be another language which is similar to yours). Otherwise, you could try utf8_unicode_ci , which uses the Unicode Collation Algorithm, but I'm not sure if that one makes this distinction.

You can also use utf8_bin , which is guaranteed to consider them different, but that comes at the expense of losing case insensitivity, which is most likely worse.

Having said that, this is not necessarily a bad thing: by ignoring the accents, the search will be more flexible, and easier to use for people who are unable to type a specific character.


尝试使用utf8_encode。


你想要utf8_bin,* _ci不区分大小写,所以重音符号被视为常规字母

链接地址: http://www.djcxy.com/p/68778.html

上一篇: 创建表时出现MySQL语法错误

下一篇: mysql的utf8字符问题