您的位置:首页 > 产品设计 > UI/UE

Escape Sequences

2015-11-27 00:02 471 查看

(这篇随笔是 C++ Primer 5th ed. pp.39-40的摘录)

Some characters, such as backspace or control characters, have no visible image. Such characters are non printable.

Other characters (single and double quotation marks, question marks, and backlash) have special meaning in the language. Our programs cannot use any of these characters directly. Indeed, we use an escape sequence to represent such characters. An escape sequence begins with a backslash ('\'). The language defines several escape sequences:

  newline      \        horizontal tab      \t      alert (bell)    \a

  vertical tab    \v         backspace        \b       double quote    \"

  backslash      \\        question mark      \?      single quote    \'

  carriage return  \r        formfeed         \f

----------------------------------------------------------------------------------------------------------------------------

We can also write a generalized escape sequence, which is \x followed by one or more hexadecimal digits or a \

followed by one, two, or three octal digits. The value represents the numerical value of the character.

Note that if a \ is followed by more than three octal digits, only the first three are associated with the \. In contrast, \x uses up all the hex digits following it.

Ordinarily, haxadecimal characters with more than 8 bits are used with extended characters sets using one of the following prefixs:

  Prefix    Meaning            Type

  u      Unicode 16 character       char16_t

  U      Unicode 32 character       char32_t

  L      wide character         wchar_t

  u8      utf-8 (string literals only)     char

--------------------------------------------------------------------------------------------------------------------------

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: