Search code examples
phpmysqlhtmlcharacter-encodingcyrillic

Russian Characters encoding trouble


I have been working with Transferable Type and MySQL (in Russian, UTF-8 encoding - is the encoding of my database). This is link http://ru.fxdailyinfo.com/. And testing here http://ru.fxdailyinfo.com/test.php.

My problem is in russian content output rendering. If I store 'привет босс' [Hello boss!] in mysql database it stored as 'Привет Boss!'.

 [Quried result:: contents from mysql database:Привет Boss!]

<!DOCTYPE HTML>
    <html lang='ru' dir='ltr' id="web_page" class='ru'>
  <head>
    <meta charset="utf-8" />
    </head>
    <body>Привет Boss!</body>

My expected output is

<!DOCTYPE HTML>
    <html lang='ru' dir='ltr' id="web_page" class='ru'>
  <head>
    <meta charset="utf-8" />
    </head>
    <body>привет босс!</body>

I am 90% sure this problem is not rendered in MySQL server. However MySQL Info

character_set_client    utf8
character_set_connection    utf8
character_set_database  utf8
character_set_filesystem    binary
character_set_results   utf8
character_set_server    utf8
character_set_system    utf8
character_sets_dir  /usr/share/percona-server/charsets/
collation_connection    utf8_general_ci
collation_database  utf8_unicode_ci
collation_server    utf8_unicode_ci
completion_type NO_CHAIN
concurrent_insert   AUTO
connect_timeout 20

Any suggestions?


Solution

  • After you connect to your database, try sending it this (assuming $dbc is the result of mysqli_connect):

    mysqli_query($dbc,"SET NAMES 'utf8'");
    

    You can also check the output of SHOW CREATE TABLE <your-table>; and make sure the CHARACTER SET for the relevant columns are utf8_unicode or something that allows extended characters.