【问题标题】:Russian Characters encoding trouble俄语字符编码问题
【发布时间】:2015-01-18 20:26:46
【问题描述】:

我一直在使用 Transferable Type 和 MySQL(俄语,UTF-8 编码 - 是我的数据库的编码)。 这是链接http://ru.fxdailyinfo.com/。并在这里测试http://ru.fxdailyinfo.com/test.php

我的问题在于俄罗斯内容输出渲染。如果我将 'привет босс' [Hello boss!] 存储在 mysql 数据库中,它将存储为 'Привет 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>

我的预期输出是

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

我 90% 确定这个问题不会在 MySQL 服务器中呈现。然而 MySQL 信息

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

有什么建议吗?

【问题讨论】:

  • 能否提供插入数据的 php 代码片段?和 phpMyAdmin 的屏幕截图浏览数据привет босс 在表中?和输出此页面的 php 代码也可能会有所帮助。

标签: php mysql html character-encoding cyrillic


【解决方案1】:

连接到数据库后,尝试发送它(假设 $dbc 是 mysqli_connect 的结果):

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

您还可以检查SHOW CREATE TABLE &lt;your-table&gt;; 的输出并确保相关列的字符集是utf8_unicode 或允许扩展字符的东西。

【讨论】:

    猜你喜欢
    • 2013-12-08
    • 2011-08-18
    • 1970-01-01
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 2016-12-27
    • 2012-08-02
    • 1970-01-01
    相关资源
    最近更新 更多