In a database field, I'm storing and returning the "body" of my email (in case it changes). In this I have \n\r characters to get new lines. But, it seems not to be working. Any thoughts:
So data in field:
'TBD.\r\n\nExpect'
And my output looks like (literal \r and \n):
TBD.\r\n\nExpect
Thoughts?
Escape sequences have no meaning within actual string objects - only when the C# parser/compiler interprets them. You want to store an actual new line in your database field rather than the 4 characters "\r\n".
It is likely that the \r\n is escaped, so the string actually returned would be equivalent to a string
myString = "\\r\\n";
So you would need to remove these extra slashes either when adding or removing from the database.
Though likely unrelated to your problem, the extra \n
you have may cause viewing problems depending on the system, editor, etc.
You could replace all occurrences of \\n\\r, etc. using:
replacedString = myString.Replace("\\r\\n", "\r\n");
This should work to fix your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With