On Tuesday, Nov 12, 2002, at 16:37 Asia/Tokyo, Daisuke Maki wrote:
I've recently converted to Perl5.8, and thus migrated all of my Japanese
encoding conversion routines to Encode.pm. It mostly works like a charm
-- it's fast, and I like it, but somehow XML::LibXML doesn't seem to
like it. I'm trying to do this:

1) parse an XML file (euc-jp encoding) with XML::libXML
2) stuff the data from the XML into an euc-jp database.
3) when doing this, I do

utf82euc( $xml->findvalue( 'foobar' ) );

where utf82euc() is a convenience function that I wrote which does:

my $octets = decode( 'utf8', $text );
return encode( 'euc-jp', $octets );

The problem is that when I call decode(), I get the error

"Cannot decode string with wide characters"
That means the value $xml->findvalue() returns is ALREADY in utf8 (with flag set); You are trying to decode what's already decoded to utf8 You can redefine utf82euc as

sub utf82euc{ return encode('euc-jp', shift ) };

Dan the Encode Maintainer



Reply via email to