Daniela
Daniela

Reputation: 139

Codeigniter email do not encode to utf8

I am using Codeigniter email library. I have some data in serbian in database with this type of characters : žčćšđ When I print it out in other palces, there is all OK with characters, so databese save it on right way.

My controller looks like this:

$config['charset'] = 'utf-8';
    $this->load->library('email');
    $this->email->initialize($config);


    foreach($email as $val): 

    $this->load->library('email');
        $this->email->from('[email protected]', 'Vojvođanska Svaštara - Mali Oglasi');
        $this->email->to('[email protected]'); 

        $this->email->subject($uid);
        $this->email->message($tekst);  

        $this->email->send();

        $info=$this->email->print_debugger();
         endforeach;
     echo json_encode(array('info'=>$info));

When I recieve email it looks lik this: pšđpšđpšđpšđ-čć.- So there is some characters, what is not encoded.

Upvotes: 2

Views: 5961

Answers (2)

ivanargulo
ivanargulo

Reputation: 324

Check that the file format is UTF-8 too. Sometimes, when using Eclipse, it sets by default to ISO-8859.

Right click on the file > Porperties > Text file encoding: UTF8.

You can apply this to all the project (WARNING: it may break up some characters)

Upvotes: 0

iLaYa  ツ
iLaYa ツ

Reputation: 4017

you have to encode strings to UTF-8, even if you expect they are already utf-8 encoded. Try php mb-convert-encoding

mb_convert_encoding($content, "UTF-8");

Upvotes: 3

Related Questions