CodeIgniter Forums
Accented characters in view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Accented characters in view (/showthread.php?tid=755)



Accented characters in view - array81 - 01-13-2015

I have some view with accented characters. I use this view as "base" for html mail.
I have problem with accented characters, in fact I cannot see it but  simbol.

This is an example of my view file:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Welcome to <?php echo $site_name; ?>!</title></head>
<body>
<div style="max-width: 800px; margin: 0; padding: 30px 0;">
èàò
</div>
</body>
</html>



RE: Accented characters in view - mwhitney - 01-13-2015

There are a couple of potential causes for this. Possibly the easiest thing to do is simply convert the text with a function like htmlspecialchars() to get the HTML entities for those characters.

Beyond that, there are many potential areas to check:
- check the encoding of the view file
- make sure you're outputting the final result using the same encoding
- Set the charset via the meta tags in your HTML head
- If you're retrieving content from a database, you will need the character set to match there, as well

In most cases, you'll want to use UTF-8 everywhere, but this is not necessarily the default anywhere. If you can't immediately find the information on how everything's encoded, you may need to look up the settings for each tool you are using (editor, web server, SQL server) to determine how to set it.


RE: Accented characters in view - Rufnex - 01-13-2015

You have to deliver you site with utf-8 encoding. Put this in your view files:

<meta charset="utf-8">


RE: Accented characters in view - array81 - 01-13-2015

(01-13-2015, 11:45 AM)Rufnex Wrote: You have to deliver you site with utf-8 encoding. Put this in your view files:

<meta charset="utf-8">

I have try to put it after <html> tag but I get the same result.


RE: Accented characters in view - Avenirer - 01-14-2015

(01-13-2015, 03:37 PM)array81 Wrote:
(01-13-2015, 11:45 AM)Rufnex Wrote: You have to deliver you site with utf-8 encoding. Put this in your view files:

<meta charset="utf-8">

I have try to put it after <html> tag but I get the same result.

Are you sure is not working? On Chrome it works. What browser (and version) are you using?


RE: Accented characters in view - array81 - 01-14-2015

(01-14-2015, 12:07 AM)Avenirer Wrote:
(01-13-2015, 03:37 PM)array81 Wrote:
(01-13-2015, 11:45 AM)Rufnex Wrote: You have to deliver you site with utf-8 encoding. Put this in your view files:

<meta charset="utf-8">

I have try to put it after <html> tag but I get the same result.

Are you sure is not working? On Chrome it works. What browser (and version) are you using?

I send it as mail to my hotmail account (for testing) and open my hotmail account with chrome v39


RE: Accented characters in view - Rufnex - 01-14-2015

Have you also checked your encoding in your databse?


RE: Accented characters in view - Avenirer - 01-14-2015

Ah... So your problem is not the view of the mail, but the way the mail is presented...

When you configure the email library do you set a charset?

Code:
$config['charset'] = 'utf-8';


http://www.codeigniter.com/userguide3/libraries/email.html#email-preferences


RE: Accented characters in view - array81 - 01-18-2015

(01-14-2015, 07:18 AM)Avenirer Wrote: Ah... So your problem is not the view of the mail, but the way the mail is presented...

When you configure the email library do you set a charset?


Code:
$config['charset'] = 'utf-8';


http://www.codeigniter.com/userguide3/libraries/email.html#email-preferences

Yes, but I have the same problem.

This is the code used to sedn the mail:
Code:
        $this->load->library('email');
        $mail_config['mailtype'] = 'html';
        $mail_config['charset'] = 'utf-8';
        $this->email->initialize($mail_config);
        $this->email->from($web_mail, $site_name);
        $this->email->reply_to($web_mail, $site_name);    
        
        $this->email->to($email);
        $this->email->subject(sprintf('Order confirmation', $site_name));
        $this->email->message($this->load->view('email/'.$type.'-html', $data, TRUE));
        $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
        $this->email->send();

The attachment file is the view used as email template.