2007/4/24, Beau E. Cox <[EMAIL PROTECTED]>:

How do I get a proper conversion from iso-8859-1 to perl's internal utf8?

Hello,

You may use Encode module's decode function to do this conversion.
ie,for this string which was 'gb2312' format,

$str = "中文";

We use decode to convert it to perl's internal utf8,

$str2 = decode('gb2312',$str);

But you can't see this $str2 since it's perl's internal encode
format.So you need to convert it to corresponding output format,like,

$output = encode('utf8',$str2);

then print it out,
print $output;

The whole things can be written one line,

$ perl -MEncode -e '$out=encode("utf8",decode("gb2312","中文"));print $out'

That would get the correct result you wanted (output with utf8).
Hope this helps.

--
Chinese Practical Mod_perl book online
http://home.arcor.de/jeffpang/mod_perl/

Reply via email to