douxing9228 2014-09-04 20:42
浏览 42

使用codeigniter转换utf-8中的视图

I have a problem with encoding, I tried to convert my html in utf8 using CodeIgniter, so my code is:

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");
}

So, my output pdf is LIMITAT? name of company,I dont't understand why Ă is not converted is use meta tag, also I use Codeigniter config: $config['charset'] = 'UTF-8'; Help me pleaaaaase, thnx in advance

  • 写回答

1条回答 默认 最新

  • douhao7889 2014-09-04 21:38
    关注

    there is no direct conversion method.you have to use str_replace or something similar.for more info you can see this:PHP converting special characters, like ş to s, ţ to t, ă to a

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向