Don't ask to ask, just ask | |
PerlMonks |
Decode XML &#xxxx; entitiesby saintmike (Vicar) |
on Dec 04, 2007 at 18:08 UTC ( [id://654893]=perlquestion: print w/replies, xml ) | Need Help?? |
saintmike has asked for the wisdom of the Perl Monks concerning the following question:
I've looked all over CPAN, but I can't find a module that offers a standard way of performing this simple transformation.
To transform an XML entity like into the corresponding utf-8-encoded Unicode character, the following substitution can be used, given that the string this is performed on is a Unicode string: Now, instead of having to write this snippet down over and over again, I'd prefer something like which I use all the time, not because URL-unescaping is terribly complicated, but because for such a common operation there ought to be a standard procedure. So ... is there a module on CPAN that does something similar? If not, I'll be happy to put one up there. By the way, XML::DOM provides a function called XmlUtf8Encode which does a lot more than calling chr(), but I guess that's because it tries to cope with older perl releases that didn't support Unicode well. Any insight on this would be appreciated as well. (Hex-entity corrected, thanks eserte.)
Back to
Seekers of Perl Wisdom
|
|