proposals/csharp-13.0/esc-escape-sequence.md
\e[!INCLUDESpecletdisclaimer]
Champion issue: https://github.com/dotnet/csharplang/issues/8657
An addition of the string/character escape sequence \e as a shortcut/short-hand replacement
for the character code point 0x1b, commonly known as the ESCAPE (or ESC) character.
This character is currently accessible using one of the following escape sequences:
\u001b\U0000001b\x1b (not recommended, see the picture attached at the bottom.)With the implementation of this proposal, the following assertions should be true:
char escape_char = '\e';
Assert.IsTrue(escape_char == (char)0x1b, "...");
Assert.IsTrue(escape_char == '\u001b', "...");
Assert.IsTrue(escape_char == '\U0000001b', "...");
Assert.IsTrue(escape_char == '\x1b', "...");
The language syntax specification is changed as follows in section 6.4.5.5:
fragment Simple_Escape_Sequence
- : '\\\'' | '\\"' | '\\\\' | '\\0' | '\\a' | '\\b' | '\\f' | '\\n' | '\\r' | '\\t' | '\\v'
+ : '\\\'' | '\\"' | '\\\\' | '\\0' | '\\a' | '\\b' | '\\f' | '\\n' | '\\r' | '\\t' | '\\v' | '\\e'
;
As well as the addition of the last line to the following table in the specifications:
A simple escape sequence represents a Unicode character, as described in the table below.
Escape sequence Character name Unicode code point \'Single quote U+0027 ... ... ... \eEscape character U+001B The type of a Character_Literal is
char.