[PerlChina] XML中文

Fayland Lam fayland at gmail.com
Wed Aug 13 00:28:53 PDT 2008


Question wrote:
> 2008/8/13 Fayland Lam <fayland at gmail.com <mailto:fayland at 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 at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm


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



More information about the China-pm mailing list