Log in

View Full Version : problem of character set encoding in php



dr-support
04-05-2007, 05:25 PM
I have a php form which submits information to an email. Everything works fine when dealing with 'normal' text. However, if a user submits "العربية", the resulting text displays as "د لله ".

The website is in 3 languages (EN, FR, AR). Page encoding is unicode...


Clearly it is an encoding problem, but I have looked around and cannot really see where to start to fix the problem. My php form submits to an external php file(contactus.php attached ), which in turn checks configuration information on an external text file.

dr-support
04-06-2007, 10:06 AM
24 h up

Twey
04-06-2007, 10:45 AM
Page encoding is unicode...There are multiple Unicode encodings. UTF-8 is currently the most common, so I'll assume you mean that.
Make sure you're setting the encoding of the email to UTF-8 too, add:
Content-Type: text/plain; charset=utf-8(or text/html, if you're using HTML email [which you shouldn't be, at least not without the user specifically saying they wish to receive HTML email]) to the headers.

dr-support
04-06-2007, 10:59 AM
the problem mr Twey is that mail informations (mailfrom, subject , body) coming from an other HTML file have (charset=utf-8) as header
how can give variables( subject body) chareset utf8 ??
for Example in ASP we have this :
mail.BodyEncoding = Encoding.GetEncoding("utf-8")
but in php how ??

please help me

Twey
04-06-2007, 12:15 PM
I just told you.

dr-support
04-07-2007, 07:19 PM
u p

Twey
04-07-2007, 08:37 PM
I'm not sure what that's meant to mean.

boxxertrumps
04-07-2007, 08:44 PM
thought there was a 5 min character limit.

dr-support
04-08-2007, 10:13 AM
my question is very simple
txt msg sent to me from a contact us with a chareset unknown

Twey
04-08-2007, 11:33 AM
And my answer was just as simple:
Make sure you're setting the encoding of the email to UTF-8 too, add:
Content-Type: text/plain; charset=utf-8(or text/html, if you're using HTML email [which you shouldn't be, at least not without the user specifically saying they wish to receive HTML email]) to the headers.Have you done this?

dr-support
04-08-2007, 04:13 PM
yes my headers has Content-Type: text/plain; charset=utf-8

dr-support
04-08-2007, 04:31 PM
my html page work fine only with charset=utf-8 but form contact us sent msg withe an other charset although that we have utf8

Twey
04-08-2007, 06:28 PM
my html page work fine only with charset=utf-8 but form contact us sent msg withe an other charset although that we have utf8Let me get this straight. Both your HTML page and the message are UTF-8? And the headers are set correctly for both?