Lo all,

I was having some trouble with my axkit app and have tracked it 
down to this.
I've googled for a solution/explanation and got about 4 pages ie 
nowhere.
When the code below is run the xml is not well formed.
To be more precise, the output via toString isn't well formed, the 
output via toFile _is_ well formed.
What seems to happening is that toString is decoding the utf string 
\x{C3}\x{84} for some reason. toFile does not do this.
This is either a bug, a feature or, as is more likely, my lack of 
understanding.
If someone could be so kind as to point me in the right direction it
would be appreciated.

John



#!/usr/bin/perl -w

use strict;
use diagnostics;
use XML::LibXML;
use Encode qw (encode encode_utf8 decode_utf8 is_utf8 from_to 
_utf8_on);

binmode(STDOUT,":raw");

my $data = "*\x{C3}\x{84}*";

my $dom = XML::LibXML::Document->createDocument('1.0', 'utf-8');

my $node = $dom->createElement('MSG');

my $text = $dom->createTextNode( $data );
$node->addChild($text);

print is_utf8($data);

$dom->setDocumentElement( $node );

my $aa = $dom->toString(0);

print $aa,"\n";

$dom->toFile('aa',0);


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to