Techie Talks

Sunday, August 19, 2007

Mysterious disappearance of \r in new line during deserialization

I was trying to deserialize an XML into a business object, and found that all my multiline strings have "\n" as the new line character as opposed to the expected "\r\n".

The culprit turned out to be the reader used for deserialization. This issue will go away if XmlTextReader is used to read the xml (instead of TextReader or StreamReader).

Labels: , ,

1 Comments:

Blogger bojan said...

You can use String.Replace("\r", "\r\n") instead. Comes in handy if you have no access/desire to alter the existing code.

Cheers,

bojan

5:03 PM  

Post a Comment

<< Home