I tried out Slimserver v6.0.2,v6.1.2 and v6.2.1b.The server produced web pages are consisted of characters of mixed encodings.Some are encoded with cp936 locale,some are in the form of utf8 of cp936, and the largest part are wrongly encoded as utf8 of latin-1.They can't be displayed correctly in web browser.
When I run perl slimserver.pl,a long list of "Malformed UTF-8 character ..." will display on the screen. The mixed encodings in web page are caused by successful/successful encoding/decoding,concatenation of utf8 character string with Chinese byte string, and carelessness about the utf8 on/off flags. I corrected some bugs.But at last I decided to solve the problem in a package. I wrote a subroutine that convert a byte string with mixed encodings into "one-encoding-only" string(utf8 character string of locale or byte string of locale). I inserted $output = Slim::Utils::HtmlAdjust::htmlReform($output); just before return \$output; in the if ($type eq 'fill') block in subroutine _generateContentFromFile in Slim/Web/HTTP.pm Now the Chinese characters display well in browses. Yesterday,I upgraded to V6.2.1.I added a statment $string = Slim::Utils::HtmlAdjust::htmlReform($string); in subroutine string in Slim/Display/graphics.pm Now the Chinese characters display well in SB2. Of course,"use Slim::Utils::HtmlAdjust;" should be added where neccessary. BTW,the "_" character is replaced with " " by slim programs for some reason and it is the second byte of many Chinese characters. e.g. Chinese character "\xE9\x5F" will become "\xE9x\20" leading to many errors.Chinese character recovery is made in Slim::Utils::HtmlAdjust."\xE9x\20" is recovered to "\xE9x\5F" This program may be useful in CJK windows. Where and how to post it? -- Renyao _______________________________________________ beta mailing list [email protected] http://lists.slimdevices.com/lists/listinfo/beta
