Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Things like "\n" (not "/n" by the way) are escape characters in <em>programming languages</em>, not inherently in text. (In particular, they're programming-language dependent.)</p> <p>If you want to make</p> <pre><code>hello\r\nthis is a test\r\nnew line </code></pre> <p>format as</p> <pre><code>hello this is a test new line </code></pre> <p>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:</p> <pre><code>static string Unescape(string text) { StringBuilder builder = new StringBuilder(text.Length); bool escaping = false; foreach (char c in text) { if (escaping) { // We're not handling \uxxxx etc escaping = false; switch(c) { case 'r': builder.Append('\r'); break; case 'n': builder.Append('\n'); break; case 't': builder.Append('\t'); break; case '\\': builder.Append('\\'); break; default: throw new ArgumentException("Unhandled escape: " + c); } } else { if (c == '\\') { escaping = true; } else { builder.Append(c); } } } if (escaping) { throw new ArgumentException("Unterminated escape sequence"); } return builder.ToString(); } </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload