【问题标题】:Convert a view in utf-8 using codeigniter使用 codeigniter 转换 utf-8 中的视图
【发布时间】:2014-09-04 20:42:52
【问题描述】:

我的编码有问题,我尝试使用 CodeIgniter 将我的 html 转换为 utf8,所以我的代码是:

public function generateTitlePage($company)
{
    $this->load->library('dompdf_gen');
    $dompdf = new DOMPDF();
    $search = array('%27', '%20', '%C3%A2', '%C3%AE');
    $replace = array('', ' ', 'â', 'î');
    $company = str_replace($search, $replace, $company);
    $html = '
        <!DOCTYPE html>
        <html>
        <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        </head>
        <body>
            <div style="margin-top:20px;text-align: center;font-weight: bold">
               LIMITATĂ'.$company.'
            </div>
        </body>
        </html>
    ';


    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream("welcome.pdf");
}

那么,我的输出 pdf 是 LIMITAT 吗?公司名称,我不明白为什么不转换 Ă 是使用元标记,我也使用 Codeigniter config: $config['charset'] = 'UTF-8';帮帮我,请提前谢谢

【问题讨论】:

    标签: php codeigniter utf-8 codeigniter-2 utf8-decode


    【解决方案1】:

    没有直接的转换方法。你必须使用str_replace or something similar。更多信息你可以看到这个:PHP converting special characters, like ş to s, ţ to t, ă to a

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 2015-09-21
      相关资源
      最近更新 更多