PHP Classes

utf8 Problem

Recommend this page to a friend!

      PHP MIME Email Message Parser  >  All threads  >  utf8 Problem  >  (Un) Subscribe thread alerts  
Subject:utf8 Problem
Summary:converting db to utf8 and the class breaks at special character
Messages:6
Author:Tom
Date:2008-05-29 16:07:43
Update:2008-05-30 07:05:56
 

  1. utf8 Problem   Reply   Report abuse  
Picture of Tom Tom - 2008-05-29 16:07:43
Hi,

i have changed and converted my mysql DB and application from latin 1 to utf8.

Problem:

If i get a utf-8 mail with special character, no problem

If i receive a ISO-8859-1 mail with special character in Subject or body, the Mail cutts bevor special character.

Have anybody a hint for me whats going here up?

  2. Re: utf8 Problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-05-29 16:47:43 - In reply to message 1 from Tom
Maybe you are not encoding the message properly when it is sent.

Can you upload a copy of the message with those problems somewhere I can see what is wrong?

  3. Re: utf8 Problem   Reply   Report abuse  
Picture of Tom Tom - 2008-05-29 18:00:24 - In reply to message 2 from Manuel Lemos
I found one reason for the body:

If the System (php applikation,mysql) runs on uft8, the class save the tmp message bodys in iso-8859-1 File. If i reload this body file to become it in db, no special characters are available. if i load the tmp body file with utf8_encode, the body is okay.
The question is, should not manage the class a utf8 System, like this:
&& !fwrite($this->body_file, utf8_encode($part['Data'])))


The problem with broken subject with cpezial chairs i don't know at this time. But i think the class should konvert it(?)

  4. Re: utf8 Problem   Reply   Report abuse  
Picture of Tom Tom - 2008-05-29 18:10:31 - In reply to message 3 from Tom
Subject Problem:

This works:

$subject = mysql_real_escape_string(utf8_encode(decodestring($decoded[$message]['Headers']['subject:']))


I think the Problem is, i must look the mail charset and if already utf8 i don't need converting. Is this right?

  5. Re: utf8 Problem   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-05-29 22:40:18 - In reply to message 3 from Tom
The class does not change the character set encoding of the message. If the message body or headers are in UTF-8, the class will return strings in UTF-8 as they arrive. If your database character set is different, you need to convert it yourself before adding to the database.

  6. Re: utf8 Problem   Reply   Report abuse  
Picture of Tom Tom - 2008-05-30 07:05:56 - In reply to message 5 from Manuel Lemos
Thank you Manuel for info. I will convert all incoming Mail to utf-8.

Greeting Tom