2008年8月13日星期三

Re: [PerlChina] XML中文

Question wrote:
> 2008/8/13 Fayland Lam <fayland@gmail.com <mailto:fayland@gmail.com>>
>
>
> binmode STDOUT 是不中的,要去把原始的 $file 转为 utf8
> 否则得用 Encode 来转为 utf8
>
>
> XML::Encoding / Unicode::String?
> perl做web的这么多,能不能给个例子?
>
> 也就是说自己读数据再encoding utf8,不用parseFile 用 parse/parsestring?
>

open(my $fh, '<', $file);
local $/ = undef;
my $string = <$fh>;
close($fh);
use Encode qw/from_to/;
from_to($string, 'gb2312', 'utf8');
use XML::Simple;
my $xs1 = new XML::Simple;
my $doc = $xs1->XMLin($string);

试试。

> --
> >: ~
> ------------------------------------------------------------------------
>
> _______________________________________________
> China-pm mailing list
> China-pm@pm.org
> http://mail.pm.org/mailman/listinfo/china-pm


--
Fayland Lam // http://www.fayland.org/
Foorum based on Catalyst // http://www.foorumbbs.com/

_______________________________________________
China-pm mailing list
China-pm@pm.org
http://mail.pm.org/mailman/listinfo/china-pm

没有评论: