How can I save character objects in .Net XDocument?

I migrate a set of services in .Net 4.0 and find (much to my disappointment) that the character objects that I create and save in XElement.Value () are โ€œrestoredโ€ to their original character values โ€‹โ€‹when I convert an XDocument object to an XML stream for HTTP response.

The escaped characters must appear in the XML document as characters (for example, ® and not ยฎ) in order to remain compatible with legacy applications that were written to allow character objects for non-Latin characters.

Is there a way (another type of document or Encoding () method or something else) Can I configure XDocument to save these character entities when creating my XML stream? Maybe there is an alternative to XDocument or XmlDocument that I can use instead?

+4
source share
1 answer

Did you try to create an XmlWriter with the encoding set to Latin-1, and then save the XDocument with it? I have not tried it, but it can make it use unnecessary character objects.

And what terrible software are you using if it doesn't even support Unicode?

0
source

Source: https://habr.com/ru/post/1338160/


All Articles