[solved?] dirty hack for the Chat character encoding problem
Posted: Mon Jul 30, 2007 1:14 am
Hi!
I tried for hours to find a decent solution to the Chat character encoding problem but without ajax experience I am totally lost. Since I need a working chat now I decided to implement a really ugly hack to circumvent the problem for now.
Here you go if you have the same problem and don't mind the bad style:
Insert this into Chat.module.php at line 327 right after $chatline=utf8_encode($chatline);:
This only corrects German special characters (äöüÄÖÜß) so far.
If you want to complete the list for other characters go to the chat, send the character you want to the chat, and copy the resulting badly encoded characters. Add a line for each character to the code above. The syntax is like this:
$chatline = preg_replace('/Ã[CHAR]/','[HTML_CHAR]',$chatline);
where [CHAR] are the characters you copied from the chat window and [HTML_CHAR] is the corresponding html-character entity (full list here: http://www.w3.org/MarkUp/html3/latin1.html).
I hope there will be a decent solution to this problem in the near future, but for now, this will do.
Cerno
I tried for hours to find a decent solution to the Chat character encoding problem but without ajax experience I am totally lost. Since I need a working chat now I decided to implement a really ugly hack to circumvent the problem for now.
Here you go if you have the same problem and don't mind the bad style:
Insert this into Chat.module.php at line 327 right after $chatline=utf8_encode($chatline);:
Code: Select all
//dirty hack *shudder*
$chatline = preg_replace('/ä/','ä',$chatline);
$chatline = preg_replace('/ö/','ö',$chatline);
$chatline = preg_replace('/ü/','ü',$chatline);
$chatline = preg_replace('/Ä/','Ä',$chatline);
$chatline = preg_replace('/Ö/','Ö',$chatline);
$chatline = preg_replace('/Ü/','Ü',$chatline);
$chatline = preg_replace('/ß/','ß',$chatline);
//dirty hack end (thank God)
If you want to complete the list for other characters go to the chat, send the character you want to the chat, and copy the resulting badly encoded characters. Add a line for each character to the code above. The syntax is like this:
$chatline = preg_replace('/Ã[CHAR]/','[HTML_CHAR]',$chatline);
where [CHAR] are the characters you copied from the chat window and [HTML_CHAR] is the corresponding html-character entity (full list here: http://www.w3.org/MarkUp/html3/latin1.html).
I hope there will be a decent solution to this problem in the near future, but for now, this will do.
Cerno