PDA

View Full Version : UTF-8 encoding in the message body


ssozonoff
01-11-2008, 09:28 AM
Hi All,

When message are imported from a mail server using POP the body content does not seem to display correctly for foreign characters.

Typically French accents are apearing as question marks.
Database tables are UTF8 and encoding header are also UTF-8.

Anyone else having problems with this?

Thanks,
Serge

4ice
01-12-2008, 05:10 PM
It is indeed possible that you have problems with some characters. But I just did a little test with the following characters:
Ç ë ì í ó ñ ö €
and all of them were perfectly stored in osTicket. Are any of these chars giving you problems?

ssozonoff
01-12-2008, 05:21 PM
Hi,

Its possible the charcters are getting stored in the database correctly in my case as well. I need to verify this. But in any case the final output is not correct for some reason.

Thanks,
Serge

ssozonoff
01-12-2008, 05:31 PM
OK, just to confirm I believe the characters are getting stored correctly in the Database so something is happening to them when they are displayed in the web browser. Again looking at the HTTP headers I am correctly sending Content-Type: text/html; charset=UTF-8

Hrmmmm .

Serge

4ice
01-12-2008, 07:00 PM
Just to be sure, you are using the latest version of osTicket right?

ssozonoff
01-13-2008, 04:06 AM
Hi,

We are using osticket_1.6.rc2

Serge

ssozonoff
01-13-2008, 09:11 AM
OK.

So what seems to be happening is that when the emails are imported using POP3 and converted to tickets the character encoding of the email message is not respected.

So even though the database tables are UTF-8 you are most likely importing a different character set into them like iso8859-1

To test this theory I added utf8_encode() to the message text output on line 210 of viewticket.inc.php

The characters were then displayed correctly.
Of course this is not the fix but seems to be an indicator that the messages (which were imported using the POP3 mechanism) stored in the database are not UTF-8 encoding.

Thanks,
Serge

Kaapo
01-21-2008, 09:58 AM
I'm having the same problem that scandinavian characters ö,ä aren't displayed correctly.
I can't find any good place in viewticket.inc.php where to place utf8_encode(). Could you show me an example where in the code you have placed it?

Thanks,
Kaapo

jaigupta
01-22-2008, 08:37 AM
How about

$headers = "From: $from" . "\r\n" .
"Reply-To: $from" . "\r\n" .
'X-Mailer: PHP/' . phpversion() . $headers ;


It worked for me

anis79
01-22-2008, 09:49 PM
As ssozonoff suggested, utf8_encode did the trick.

I haven't exactly the time right now to dig deeply into it but this is a quick work around that goes a little bit further than ssozonoff solution:

Actually I've added the utf8_decode at the pop3 class in order to encode the message right before it is saved in DB. This will make it work without encoding in all the files that display the message (ex. showticket files).

In /include/class.pop3.php, line 185 and 186 becomes:

$var['subject']=utf8_encode(imap_utf8($mailinfo['subject'])); $var['message']=Format::stripEmptyLines(utf8_encode($this->getBody($mid)));

anis79
01-23-2008, 12:03 AM
As the previous work around concerning email reception and storage in utf8, this workaround will let the clients receive emails from osTicket without breaking the special characters.

In /include/class.misc.php replace line 69 by this one:

mail($to,utf8_decode($subject),utf8_decode($messag e),trim($headers));

Again, this is only a work around. A more global fix must be done in order caracter encodings in general.

peter
01-23-2008, 01:09 AM
Another thread with further discussions on the subject http://osticket.com/forums/showthread.php?t=201

feel
03-03-2008, 08:23 AM
Hi there,

Since you dont told witch is the original line 69, I'm a little afraid to change it.. Can You confirm that the original line 69 is this?
// mail($to,$subject,$message,trim($headers));

Thank You :rolleyes:


As the previous work around concerning email reception and storage in utf8, this workaround will let the clients receive emails from osTicket without breaking the special characters.

In /include/class.misc.php replace line 69 by this one:

mail($to,utf8_decode($subject),utf8_decode($messag e),trim($headers));

Again, this is only a work around. A more global fix must be done in order caracter encodings in general.

innerself
08-18-2008, 04:42 PM
I'm also having problems, and I do not know how to solve. someone knows?

in the database the text appears ok, but on display in the inbox appears the characters exchanged. help me!!!