You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by ddt <dd...@drac.com> on 2003/03/27 17:17:13 UTC
Encoding problem
Maybe this is not the right list to address my problem, but it's the only
place I've seen where I could post my problem, if there's any other
list/mail/etc. let me know it.
Having this little perl program running (Perl 5.8.0), Perl-Xerces-2.1.0-0 and
xerces-c 2.1.0
Compiled with the following options:
./runConfigure -plinux -cgcc -xg++ -minmem -nsocket -tnative -rpthread
------->8 cut here
#!/usr/bin/perl
###
#
# TEST.xml:
#
# <?xml version="1.0" encoding="iso-8859-1" standalone="no" ?>
#
# <test>TRAÇA</test>
#
###
use XML::Xerces;
### Parse the TEST.xml
$parser = XML::Xerces::XercesDOMParser->new();
eval {$parser->parse ("./TEST.xml")};
XML::Xerces::error($@) if ($@);
### Obtain doc and root node
my $xml_doc = $parser->getDocument();
$node_root=$xml_doc->getDocumentElement();
# Prints
printf "\n-->ORIGINAL TEXT:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
$node_root->getFirstChild()->setNodeValue("Catala");
printf "\n-->ASCII ONLY:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
$node_root->getFirstChild()->setNodeValue("Català");
printf "\n-->NON ASCII:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
$node_root->getFirstChild()->setNodeValue("Franca");
printf "\n-->ASCII ONLY:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
$node_root->getFirstChild()->setNodeValue("França");
printf "\n-->NON ASCII:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
printf "\n-->RESULTING TEXT:
".$node_root->getFirstChild()->getNodeValue()."<--\n\n";
my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
my $writer = $impl->createDOMWriter();
$writer->setEncoding("iso-8859-1");
my $target = XML::Xerces::MemBufFormatTarget->new();
$writer->writeNode($target ,$xml_doc);
printf $target->getRawBuffer();
------->8 cut here
The result I get is:
------->8 cut here
-->ORIGINAL TEXT: TRAÇA<--
-->ASCII ONLY: Catala<--
-->NON ASCII: <--
-->ASCII ONLY: Franca<--
-->NON ASCII: <--
-->RESULTING TEXT: <--
<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?><test></test>
------->8 cut here
I loose every non ascii string I write into the XML Nodes, I have no clue nor
idea to what to do to fix it, I've tried to use the Encode and utf8 perl
modules without the same results, any help would be really apreciated,
thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Encoding problem
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
Hi,
Sorry for writing back so late.
"ddt" <dd...@drac.com> writes:
> Maybe this is not the right list to address my problem, but it's the only
> place I've seen where I could post my problem, if there's any other
> list/mail/etc. let me know it.
I've run your program with XML-Xerces-2.5.0-0 and it works
correctly. My suggestion is to check your locale setting when running
the program:
~/work/xml-xerces/perl-2.5 $ echo $LANG
en_US
This will affect what code page Xerces uses by default - if it is set
to 'C' then you will not be using unicode.
Cheers,
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Encoding problem
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"ddt" <dd...@drac.com> writes:
> A Divendres 28 Març 2003 04:06, Jason E. Stewart va escriure:
> > "ddt" <dd...@drac.com> writes:
> > > I loose every non ascii string I write into the XML Nodes, I have no
> > > clue nor idea to what to do to fix it, I've tried to use the Encode
> > > and utf8 perl modules without the same results, any help would be
> > > really apreciated, thanks.
> >
> > Hmm... Seems like a bug. I'm hoping that the problem is in
> > Xerces-C. They were having some encoding problems in the 2.1 series.
>
> So I should better upgrade to 2.2 series, but there's no PERL interface for
> them, very bad point =:\
You are correct. There were a couple of messages on the list that
indicated building it for 2.2 was really easy - just re-run SWIG using
the existing interface file with the Xerces-C-2.2 codebase.
Sorry, but I have no spare tuits at the moment for this.
> > Can you try this with 2.0?
>
> Same results with xerces-c-2.0.0 and PERL-Xerces-2.0.0-3
Bummer. Sorry. Looks like 2.2 is your hope.
Cheers,
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Encoding problem
Posted by ddt <dd...@drac.com>.
A Divendres 28 Març 2003 04:06, Jason E. Stewart va escriure:
> "ddt" <dd...@drac.com> writes:
> > I loose every non ascii string I write into the XML Nodes, I have no
> > clue nor idea to what to do to fix it, I've tried to use the Encode
> > and utf8 perl modules without the same results, any help would be
> > really apreciated, thanks.
>
> Hmm... Seems like a bug. I'm hoping that the problem is in
> Xerces-C. They were having some encoding problems in the 2.1 series.
So I should better upgrade to 2.2 series, but there's no PERL interface for
them, very bad point =:\
> Can you try this with 2.0?
Same results with xerces-c-2.0.0 and PERL-Xerces-2.0.0-3
> Cheers,
> jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Encoding problem
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"ddt" <dd...@drac.com> writes:
> I loose every non ascii string I write into the XML Nodes, I have no
> clue nor idea to what to do to fix it, I've tried to use the Encode
> and utf8 perl modules without the same results, any help would be
> really apreciated, thanks.
Hmm... Seems like a bug. I'm hoping that the problem is in
Xerces-C. They were having some encoding problems in the 2.1 series.
Can you try this with 2.0?
Cheers,
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org