Another alternative is the 'xmlchar' library, which Zarella Rendon & I based on some earlier musings of Tim's. It is just a set of XML elements, one for each special character, that you can embed in your documents. Then there is an XSLT stylesheet that lets you do a final post-process to convert the xmlchar elements into numeric character references. Simplistic, but it works. So far it only covers the HTML special characters, but that contains 80% of the special characters used by 80% of the people. See
http://sourceforge.net/projects/xmlchar/