About the C# Unescape
Paste a literal lifted from a .cs file, a decompiler or an exception message and get the characters it stands for. All eleven simple escapes are handled, together with the three numeric forms: \xH through \xHHHH, the fixed \uXXXX, and \UXXXXXXXX for code points beyond the basic multilingual plane, which decodes straight to the surrogate pair a .NET string would hold.
The variable-length hex escape is greedy in C# and greedy here: it consumes up to four hexadecimal digits, so \x41B is one character, U+41B, not the letter A followed by B. Knowing that rule is often the whole reason a string looked corrupted in the first place.
Switch to verbatim mode for an @ literal. There the only escape is a doubled quote, and a lone double quote inside the body is reported as an error because the compiler would end the literal at that point. A leading @" and its closing quote are stripped for you in that mode; in regular mode a matching pair of plain quotes is stripped instead. An unrecognised escape stops the conversion with its position, which usually means the string was written for JavaScript or Java rather than C#.
How to use
- Paste the C# literal into the left pane.
- Set Literal kind to match: regular for a plain literal, verbatim for one starting with @.
- Copy the decoded text on the right.
Common questions
- How many digits does \x read?
- Up to four. It stops at the first character that is not a hexadecimal digit, which is why \x41B decodes as a single character.
- What is \U0001F30A?
- An eight-digit escape for a code point outside the basic plane. It decodes here to the wave emoji, exactly as .NET would store it.
- Why does verbatim mode reject a single quote character?
- Inside an @ literal a lone double quote terminates the string. Only doubled quotes can appear in the body, so a single one means the input is not really verbatim.
- Does it handle \a and \v?
- Yes. Both are part of the C# simple escape set and decode to U+0007 and U+000B.