0

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.

  • can you please edit your question with the results of a `SHOW CREATE TABLE` for the table in question? Also, are you *sure* that you are using the right `SET NAMES` query? The one you're using looks wrong -- you're specifying a *collation* name ("_ci") in both positions, which isn't valid. – Charles Apr 02 '11 at 05:01
  • 1
    When you say "screen" are you talking browser or are you talking in PHP inside your editor? If its inside your editor then you'll need to make sure your editor can handle those encodings. For example in vim you need to `:set enc=utf-8`. – Yzmir Ramirez Apr 02 '11 at 05:20
  • Thanks for the help guys! Its strange, although in the editor it *seems* to be shown the characters (asking politely to it, otherwise, it shows ascii), in the middle, in the upload to the server, characters fly away... server says it works on utf8 and the sql data it seems to be correctly set up... where could I have the glitch? (I never worked in utf, so I dunno where I could have the glitch, since ) – BlondieMarlenne Apr 04 '11 at 15:30
  • I just change the set names to: mysql_query("SET NAMES 'UTF-8'"); – BlondieMarlenne Apr 05 '11 at 05:22
  • ... and still mistakes are (the last strange names settings, were a consecuence of desperation, of attempting something new! xd ) – BlondieMarlenne Apr 05 '11 at 05:25

2 Answers2

3

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.

Community
  • 1
  • 1
jeff forest
  • 698
  • 5
  • 8
0

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.

Wh1T3h4Ck5
  • 8,399
  • 9
  • 59
  • 79