Ok,
I have a string in a sql table like this
hello /r/n this is a test /r/n new line.
When i retrieve this string using c# for a textbox using multiline i expect the escape chars to be newlines.
But they are not and what happens is i get the line exactly as it is above.
It seems that the string returned from the table is taken as literal but i want the newlines!
How do i get this to work?
Thanks in advance..
Things like ‘\n’ (not ‘/n’ by the way) are escape characters in programming languages, not inherently in text. (In particular, they’re programming-language dependent.)
If you want to make
format as
you’ll need to do the parsing yourself, replacing ‘\r’ with carriage return, ‘\n’ with newline etc, handling ‘\’ as a literal backslash etc. I’ve typically found that a simple parser which just remembers whether or not the previous character was a backslash is good enough for most purposes. Something like this:
There are more efficient ways of doing it (skipping from backslash to backslash and appending whole substrings of non-escaped text, basically) but this is simple.