【问题标题】:Codeigniter curly quotes (despite UTF-8 collation)Codeigniter 花引号(尽管 UTF-8 排序规则)
【发布时间】:2013-10-17 01:21:37
【问题描述】:

我正在使用一个简单的表单将字符串写入数据库,但大括号(检索时)被显示为特殊字符。

到目前为止,我已经尝试将表格排序规则更改为 UTF-8 以及使用 CodeIgniter Typography 类:

 1. alter table test.vocab convert to character set utf8 collate
    utf8_unicode_ci;
 2. $this->load->library('typography'); 
    $data['item'] = $this->typography->auto_typography($data['item'], FALSE);

但这并没有帮助。输出如下所示:

如果需要,我会发布更多代码。请帮忙。

【问题讨论】:

  • 听起来这不是你的数据库。您是否在 html 文件标题中将页面字符集设置为 utf-8? <meta charset="utf-8" /> 。另一件事可能是您的语言环境。尝试使用setlocale()

标签: php codeigniter utf-8 quotes


【解决方案1】:

谢谢大家,但看来我需要的是mb_convert_encoding() 函数:

$i['item'] = mb_convert_encoding($i['item'], 'HTML-ENTITIES', 'UTF-8');

非常感谢您抽出时间发表评论或回答。

【讨论】:

    【解决方案2】:

    我在迁移的数据库中遇到了类似的问题。原来我需要将“UTF-8”转换为“Windows-1252”。

    我通过运行下面的代码并检查哪个组合看起来正确发现了:

    $html = 'Your HTML here';
    
    
    $charsets = array(  
        "UTF-8", 
        "ASCII", 
        "Windows-1252", 
        "ISO-8859-15", 
        "ISO-8859-1", 
        "ISO-8859-6", 
        "CP1256"
        ); 
    
    
     foreach ($charsets as $ch1) { 
          foreach ($charsets as $ch2){ 
           echo "<h1>Combination $ch1 to $ch2 produces: </h1>".iconv($ch1, $ch2, $html); 
        } 
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-14
      • 2011-12-08
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 2011-09-28
      • 1970-01-01
      • 2020-03-14
      相关资源
      最近更新 更多