http://www.perlmonks.org?node_id=1090730


in reply to XML::Smart and UTF-8

1. It's so so wrong, but you need to encode the data before passing to to XML::Smart. You seem to be doing that already.

2. You need to pass decode => 1 to save.

use strict; use warnings; use Encode qw( encode_utf8 ); use XML::Smart qw( ); my $text = chr(0xC9); my $utf8 = encode_utf8($text); my $doc = XML::Smart->new('<?xml version="1.0" encoding="UTF-8"?><root +></root>'); $doc->{root}{node}{CONTENT} = $utf8; $doc->save('a.xml', decode=>1);