[bug] garbled characters in some plugins
Posted: Fri Jun 23, 2006 12:23 am
Although s9y supports many languages including east Asian languages, there are still some minor bugs on Asian languages support. When using s9y to build a blog of a multibyte language (such as Chinese, Japanese, etc), sometime you could find garbled characters were shown up in sidebar.
At least, garbled characters occur in sidebar when using the internal plugin "serendipity_archives_plugin" and the sidebar plugin "serendipity_plugin_comments".
There are two possible reasons why the garbled characters occur: 1. the web server doesn't support mb_string module; 2. PHP functions like "wordwrap" etc don't support for multibyte strings.
Here are the solution I found to solve the problem. The solution works for s9y v0.8.x to v1.0.
1. For internal plugin "serendipity_archives_plugin":
In file "./include/lang.inc.php", check line 63 (in function serendipity_mb()). The original code is:
Modify it to:
2. For sidebar plugin "serendipity_plugin_comments"
In file "...../serendipity_plugin_comments.php, from line 153 to line 202 (in function generate_content(&$title)). Modify the following:
2.1. replace "$serendipity['lang'] == "ja"" to
2.2 For those multibyte functions like mb_strimwidth() and mb_strlen(), add the last parameter for encoding selection.
For exmaple:
Original source code:
After modification:
I wrote a Chinese blog discussing this problem:
http://www.deminy.net/blog/archives/4214-y.html
At least, garbled characters occur in sidebar when using the internal plugin "serendipity_archives_plugin" and the sidebar plugin "serendipity_plugin_comments".
There are two possible reasons why the garbled characters occur: 1. the web server doesn't support mb_string module; 2. PHP functions like "wordwrap" etc don't support for multibyte strings.
Here are the solution I found to solve the problem. The solution works for s9y v0.8.x to v1.0.
1. For internal plugin "serendipity_archives_plugin":
In file "./include/lang.inc.php", check line 63 (in function serendipity_mb()). The original code is:
Code: Select all
return mb_strtoupper(mb_substr($args[1], 0, 1)) . mb_substr($args[1], 1);
Code: Select all
return mb_strtoupper(mb_substr($args[1], 0, 1, mb_detect_encoding($args[1])), mb_detect_encoding($args[1])) . mb_substr($args[1], 1, mb_strlen($args[1], mb_detect_encoding($args[1])), mb_detect_encoding($args[1]));
In file "...../serendipity_plugin_comments.php, from line 153 to line 202 (in function generate_content(&$title)). Modify the following:
2.1. replace "$serendipity['lang'] == "ja"" to
Code: Select all
($serendipity['lang'] == "ja" || $serendipity['lang'] == "cn" || $serendipity['lang'] == "zh" || $serendipity['lang'] == "ko" || $serendipity['lang'] == "tw" || $serendipity['lang'] == "tn")
For exmaple:
Original source code:
Code: Select all
mb_strlen( $comment)
Code: Select all
mb_strlen( $comment, mb_detect_encoding($comment))
http://www.deminy.net/blog/archives/4214-y.html