Due to current implementation details, this function can be used as an xmlEncode function. Currently, all named entities used by this function are also xml predefined named entities. They are < > " & encoded as < > " and &. Other entities are decimal-encoded like  . Since these details are not currently in the official documentation, the behaviour could change in future versions, breaking code that uses this function for xml encoding.
If you go this route, make sure also to sanitize characters in the range \x0-\x19 except CR, LF, and TAB. This character range is forbidden in XML (http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char).