开发者

Some characters fail to show using UTF-8

I am having problems getting characters from Slavic languages, like Š. When they are included in output, they appear as the diamond question mark symbol.

My database connection is set to utf8 using:

@mysql_query("SET NAMES 'utf8_unicode_ci' COLLATE 'utf8_unicode_ci'");

Most multilingual characters appear on screen. I'm not sure that I have properly set up the charset. It seems to work in Hungarian, Spanish, Portuguese, just not Slavic!

Where could the problem be?

The field has a multitude of possible characters in it, which makes it impossible to choose a specific 开发者_开发知识库non-utf8 charset like latin2.

This is a brand new database, created from scratch. phpMyAdmin shows the characters on screen, so I guess the problem isn't with MySQL, but is PHP. However, I have set up the proper utf8 declarations.


Spent hours to check and test all the possible areas. At last I found solution here:

UTF-8 all the way through The top answer helps.

My problem found to be "Data Access". fix using

$set_utf = mysql_query("SET NAMES 'utf8' ") 
          or die(mysql_error());      

Hope it helps someone too.


Try to replace 'utf8_unicode_ci' with 'utf8_general_ci'.

E.g. I use

@mysql_query("SET NAMES 'utf8_general_ci' COLLATE 'utf8_general_ci'");

to show specific characters on my site from Serbian latin such as šđčćž and Serbian cyrillic (абвгдђежзијклљмнњопрстћуфхцчџш). I don't know if this causes your problem because I have never used 'utf8_unicode_ci'.

Put more details and some piece of code in your original question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜