print encode('gb2312', $str), "\n";

在 2010年7月8日 上午10:36,hfahe <[email protected]>写道:

> print encode("utf8", $str);
>
> => aaa你好bbb
>
>
>
>
> >#!/usr/bin/perl
> >
> >use Encode qw/encode decode/;
> >
> >my $str = "aaa\x{4f60}\x{597d}bbb";  #这大概是个合法的utf8字符串吧?
> >print $str, "\n";
> >
> >print encode('gb2312', decode('utf-8', $str)), "\n";
> >
> >D:\>perl decode.pl
> >Wide character in print at decode.pl line 6.
> >aaa浣�濂�bbb
> >Cannot decode string with wide characters at 
> >C:/strawberry/perl/lib/Encode.pm li
> >ne 174.
> >
> >
> >这是怎么回事呢?
> >
> >--
> >您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> >要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> >要取消订阅此网上论坛,请发送电子邮件至 [email protected] 
> ><perlchina%[email protected]>。
> >若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
> >
>
>
>
>  --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>



-- 
Azure.Wang

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复