0

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

erhanelu ion
  • 71
  • 1
  • 4
  • 12

1 Answers1

0

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

Community
  • 1
  • 1
Suchit kumar
  • 11,809
  • 3
  • 22
  • 44