Search code examples
c#ms-wordcontrol-characters

Escape codes for control characters in C# string


I want to find the codes for the below control characters used in Microsoft Word.

enter image description here

I have found some of them. Please correct me if I am wrong. I have browsed the web for them. But I was unable to find some of the codes.


Solution

  • The list of available escape symbols is this one, from What character escape sequences are available? (by Jon Skeet):

    \' – single quote, needed for character literals
    \" – double quote, needed for string literals
    \\ – backslash
    \0 – Unicode character 0
    \a – Alert (character 7)
    \b – Backspace (character 8)
    \f – Form feed (character 12)
    \n – New line (character 10)
    \r – Carriage return (character 13)
    \t – Horizontal tab (character 9)
    \v – Vertical quote (character 11)
    \uxxxx – Unicode escape sequence for character with hex value xxxx
    \xn[n][n][n] – Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx)
    \Uxxxxxxxx – Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)
    

    If the one you need isn't directly available as a simple escape code, you can use the hexadecimal escape. In your case, for example, \x0E for 14 or \x15 for 21. As stated in Jon Skeet's comment: it's better to use the Unicode version, i.e. \u000e and \u0015.