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 u开发者_高级运维tf, 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.
try using utf8_encode.
you want utf8_bin, *_ci is case insensitive, so accents are treated as the regular letter
精彩评论