Is there a way in the .NET class library to encode a string so that any character for which a named entity exists is replaced to use this named entity? HttpUtility.HtmlEncode doesn't appear to help:
// Result is "$", would like "€" instead
var encoded = HttpUtility.HtmlEncode("€");
I think you would have to get your hands dirty and just grab the canonical list of named entities from the specification and then create a loop that, for every named entity, simply replaces every occurrence of that character with the corresponding entity reference.