【问题标题】:YII: UTF8 encoding not working?YII:UTF8 编码不起作用?
【发布时间】:2013-03-15 09:13:51
【问题描述】:

我从网站上抓取了数据。该数据被放置在数据库中。当我打印数据时:

print $row->description;

它看起来像这样:

• Shoot great photos in low light with bright lens• 

我之前可以通过添加以下内容来解决此问题:

header('Content-Type: text/html; charset=UTF-8');
mb_internal_encoding('UTF-8');

我现在尝试将它添加到 YII 的 index.php 中,但输出没有改变。我也试过:

$decoded = utf8_decode($row->description);
print $decoded;

然后我得到:

�?� Shoot great photos in low light with bright lens�?�

我怎样才能让它在 YII 中工作?

【问题讨论】:

  • 您确定您的数据库在utf8utf8_general_ci 中吗?尝试创建数据库test CHARACTER SET utf8 COLLATE utf8_general_ci;
  • Yii 与 utf8 完美兼容,问题出在数据库

标签: php encoding utf-8 character-encoding yii


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2013-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-23
    • 2013-07-19
    相关资源
    最近更新 更多