Subject: | incorrect decoding for UTF-8 strings (double decoding) |
here is double-decoding code as in Net::OAuth::Message::encode()
if (Encode::is_utf8($str)) {
$str = Encode::decode_utf8($str, 1);
}
please note that;
- Encode::is_utf8($str) returns true if $str is a (decoded) "string".
- Encode::decode_utf8($str) decodes "UTF-8 octets" into "string".
so, the code above means "if $str is a string, decode it as a UTF-8
octets." it's double-decoding.
if you want to get "string" here, change the code as below;
if ( !Encode::is_utf8($str) ) {
$str = Encode::decode_utf8($str, 1);
}
thx.