I’m not too fluent with the perl XML libraries (actually, I really suck at understanding encoding in general), all I’m doing is taking a string that possibly has characters such as “à” and putting it in an XML file, but when I open the file, I get an encoding error at the line containing such a character.
So I just need a lightweight way to take a string and encode it for XML.
Your XML should specify UTF-8 encoding. For example:
There’s a lot of good information at UTF-8 and Unicode Standards.
Your Perl program should also be set its output filehandle to the UTF-8 encoding so it writes the data correctly. See the perl documentation for open, for instance.
The only XML-specific escaping you need is for the XML reserved characters. See Where can I get a list of the XML document escape characters? on Stackoverflow.
You can use Perl’s XML::Code or a similar module to escape the XML-specific chars