Page 1 of 1

Problem with special characters in comments [SOLVED]

Posted: Sun Apr 24, 2011 6:20 pm
by WebComPas
Hallo!

Today someone added a comment to an entry in my blog. This comment contained an "ε" (Epsilon). Within the email which was sent for moderation everything was OK. But within the comment showed on my blog this character was replaced by a "?" (see original). But don't confuse this with the character showed when the character encodings are not correct!
To solve this problem I tried to replace this question mark manually with the correct character, but without success.

Does anyone have an idea why this doesn't work or if this could really be a bug?

Regards,
Pascal

Re: Problem with special characters in comments

Posted: Mon Apr 25, 2011 9:57 am
by Timbalu
Hi
But don't confuse this with the character showed when the character encodings are not correct!
Pardon?

The symbol needs to be from the same character set as your page and database is set for.
As your page is set to UTF-8, you need to check the database settings to be in UTF-8 format too.

Are you using the most recent MySQL version? This one should have charset support. Changes will only effect new entries.

ε is part of unicode ε ε ε

Re: Problem with special characters in comments

Posted: Mon Apr 25, 2011 11:26 am
by WebComPas
I know, that all the encodings have to be set correctly. But this can't be the problem, because other special characters (for example the German umlauts) work without problems.
Checking the hex dump of this page also confirmed that the HTML code really contains a question mark (0x3F UTF-8).
So there must be another reason for this strange behaviour.

Re: Problem with special characters in comments

Posted: Mon Apr 25, 2011 1:24 pm
by Timbalu
Since the email was send by GET/POST data and the show comment is build by database data, this is the only way I can think of. Did you check the correct table for comments?

Re: Problem with special characters in comments

Posted: Mon Apr 25, 2011 3:42 pm
by WebComPas
Up to now I always tried to edit the comment using the comment edit form within the admin area. Now I tried to execute the corresponding UPDATE query:

Code: Select all

UPDATE blog_comments SET body='ebenfalls danke - ε/2' WHERE id=209;
This resulted in the following error message:
Warning: #1366 Incorrect string value: '\xCE\xB5/2' for column 'body' at row 1
So I checked my database for the specified collations. Most tables had utf8_general_ci but some (including the comments table) had latin1_swedish_ci. After I had changed this the problem concerning the Epsilon didn't occur anymore.

Re: Problem with special characters in comments

Posted: Mon Apr 25, 2011 4:01 pm
by Timbalu
Well done.
That is the sort of solution my answers were heading to. :wink:
latin_swedish has a build in umlaut support, as far as I remember.