It seems to work for me -- as far as I understand what you're asking. I took your code, commented out your placeholder substitutions, and ran it, and it outputs an XML file with the apostrophes and quotation marks intact. Any proper handling of UTF-8, which XML::Writer supports, ought not to mess with your character encoding. What do you mean that these characters "are not encoded" by XML::Writer? What OS are you running Perl under, and what is the output you are getting?