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(''); $doc->{root}{node}{CONTENT} = $utf8; $doc->save('a.xml', decode=>1);