I am facing this problem where due to multibyte characters the string value changes when returned from a function.Please consider below statements
print "charEncoding string val = " . $enc->($val) . "\n\n";
#prints charEncoding string val = 歡迎來到雅虎!
my $encoded = $enc->($val); <---- $encoded is not same as $enc->($val).
print "\n charEncodingo $encoded == $val " ;
#prints charEncodingo æ¡è¿Žä¾†åˆ°é›…虎! == 歡迎來到雅虎!
Well … yeah. The purpose of most functions, including
Encode::encode_utf8, is to change the value of the input. The input toEncode::encode_utf8may contain wide characters (whereord($char) > 255), but the output is always a byte string (whereord($char) <= 255is true for every character in the string).The part of your question that is hard to believe is your first sample output,
where you suggest that the output of
Encode::encode_utf8contained wide characters. You should double check that part.