#!/usr/bin/perl
use Encode;
use Encode::Guess qw/utf8 euc-cn gbk utf-16le/;
$string="出征进行曲";
$string=encode('gbk',$string);
$decoder = guess_encoding($string);
$info=$decoder->decode($string);
print "$info\n";
On 3月19日, 下午9时24分, Okàjn <okajn...@gmail.com> wrote:
> use Encode::Guess qw/utf-8 euc-cn gbk utf-16le/;
> 改为
> use Encode::Guess qw/utf8 euc-cn gbk utf-16le/;
>
> 运行结果:
>
> Wide character in print at ./test.pl line 7.
> 出征进行曲
>
> 2009/3/19 Calvin <calvin.n...@gmail.com>
>
> > 按照網上搜索到的 Encode:;Guess 的資料,寫了個 test.pl,內容:
>
> > #!/usr/bin/perl
>
> > use Encode;
> > use Encode::Guess qw/utf-8 euc-cn gbk utf-16le/;
> > $string="出征进行曲";
> > $decoder = guess_encoding($string);
> > $info=$decoder->decode($string);
> > print "$info\n";
>
> > 這個 test.pl 保存成 utf8 txt檔案,執行,出錯:
>
> > Can't locate object method "decode" via package "utf-8-strict or
> > utf8" (perhaps you forgot to load "utf-8-strict or utf8"?) at ./
> > test.pl line 6.
>
> > 按照網上的例子和官方說明,Encode::Guess是這樣用的沒錯啊,怎麼回事呢?
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---
没有评论:
发表评论