I'm using Foswiki and met really weird problem. I'm using LDAP server to authenticate people, and found entries with Chinese is encoded to utf-8 even if it's already utf-8. Here is what i did
- I run this test codes in commandline, and gets the right output
$str = "程洋" #they're chinese words print STDERR "string is $str";
$str =~ s/(.)/sprintf("0x%x ",ord($1))/eg;
print STDERR "string hex is $str";
->程洋
->0xe7 0xa8 0x8b 0xe6 0xb4 0x8
I can't using code sample
on these codes, seems that the string expression confuse the markdown system.sorry for that.
- I run the same codes in Foswiki plugin system which is held by apache2, in this environment,
print STDERR
will automatically redirect into /var/log/apache2/error.log, this time i get such output->\xc3\xa7\xc2\xa8\xc2\x8b\xc3\xa6\xc2\xb4\xc2\x8b ->0xe7 0xa8 0x8b 0xe6 0xb4 0x8b
As you can see, the words are escaped into url-like string, if it's 0xe7\xa8\x8b\xe6\xb4\x8b
Then i think it's alright, but they're encoded to utf-8 again even if it's already utf-8, but the hex is still OK. It not only happened to print
, things on web page will also shows like this and result in mess codes of any Chinese words, why?