in reply to Convert word special characters

In case it should turn out that Word can't encode the XML itself, you could use

use HTML::Entities qw(encode_entities_numeric); # unicode/character string my $in = qq(Sample data & and text for some <conversion> \x{201C}text\ +x{201D}.); print encode_entities_numeric($in); __END__ Sample data &#x26; and text for some &#x3C;conversion&#x3E; &#x201C;te +xt&#x201D;.

(that is, if you can get away without the (IMHO superfluous) leading zeros in the hex values...)