Accent in comment field

Asked

Viewed 127 times

3

I need a help for a situation that seemed simple, I have a form with a comment field and when sending this comment by email the same appears all disfigured, I’m using the phpmailer.

The code page on the contact page looks like this:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 

And on the process page I’ve tried some tips passed, but none successfully, I’ve tried the utf8_decode, utf8_encode, '=? UTF-8? B? '. base64_encode($message). '?= ', I have already put in the process page the following codes:

ini_set('default_charset','UTF-8'); e
header(“Content-Type: text/html; charset=ISO-8859-1“,true) 

And you didn’t either. Can someone give me some hint?

  • Have you tried utf8_decode($message) ?

  • Hello @abfurlan, yes, I’ve tried this solution and the message is coming out like this: soon

  • This doesn’t make sense, See ini_set as utf-8 and sending the headers to the client as ISO (latin1), or one or the other.. Leonardo Bosquett’s answer explains better...

2 answers

7

If your page is actually with charset iso-8859-1, you can make use of the PHP function utf8_encode() (English) to encode it in UTF-8.

Note:

In Phpmailer, you must specify the charset to be used for sending the message:

$mail->CharSet = 'UTF-8';

Anyway, the charset Phpmailer by default is the iso-8859-1 as can be seen in documentation (English) which indicates that your page will not be on iso-8859-1, at least the file that sends the email.

4

As resolved in the comments:

The issue was resolved by applying the charset standardization in the relevant fields:

  • Code behind the page: call the function header with charset=utf-8 on all requests.
  • Save documents to UTF-8 (it is possible to convert a document from ISO-8859-1 to UTF-8 by the notepad)
  • In the HTML file the meta tag that defines the charset must be present and specify that the document is in UTF-8.

The request and response in HTTP will now always be working in UTF-8, in the case of Phpmailer you can use the utf8_decode function to work with the messages if necessary or specify your Charset attribute also for UTF-8 (both forms carry out a conversion process).

  • The problem was solved following @Leonardobosquett’s tip, I patronized the contact page with UTF-8 and on the sending process page also and to complete I used the utf8_decode also suggested.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.