Welcome Guest, Not a member yet? Register   Sign In
Accented characters in view
#1

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>
Reply
#2

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.
Reply
#3

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

<meta charset="utf-8">

Reply
#4

(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.
Reply
#5

(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?
Reply
#6

(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
Reply
#7

Have you also checked your encoding in your databse?

Reply
#8

(This post was last modified: 01-14-2015, 07:20 AM by Avenirer.)

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/li...references
Reply
#9

(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/li...references

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB