Posts Tagged ‘ Escape Sequences ’

Escape Sequences

Escape characters are part of the syntax for many programming languages, data formats and communication protocols. For a given alphabet an escape character’s purpose is to start character sequences (so named escape sequences) which have to be interpreted differently from the same characters occurring alone. An escape character may not have its own meaning, so all escape sequences are of 2 or more characters.


If I run this little application I get this result:

So by using two characters (\n) I can get my message displayed in two lines.

The most interesting character is the backslash itself.

This gives me the following error message:

Apparently the backslash is just recognized when followed by a second backslash.

The C# compiler recognizes the following character escape sequences:

\ ‘       single quote, needed for character literals

\ ”      double quote, needed for string literals

\ \      backslash

\ 0      Null

\ a      Alert

\ b     Backspace

\ f      Form feed

\ n      New line

\ r       Carriage return

\ t       Horizontal tab

\ v       Vertical quote

\ u       Unicode escape sequence for character

\ U      Unicode escape sequence for surrogate pairs.

\ x       Unicode escape sequence similar to “\u” except with variable length.


To be continued…

%d bloggers like this: