2 Lexical conventions [lex]2.13 Literals [lex.literal]2.13.2 Character literals [lex.ccon]
| 2 词法约定 【词法】2.13 文字量 【词法.文字量】2.13.2 字符文字量 【词法.字符常量】
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
character-literal:' c-char-sequence' L' c-char-sequence' c-char-sequence: c-char: escape-sequence: simple-escape-sequence: one of octal-escape-sequence: hexadecimal-escape-sequence:
| 字符-文字量:' c-字符-序列' L' c-字符-序列' c-字符-序列: c-字符: 转义-序列: 简单-转义-序列: 下列之一 八进制-转义-序列: 十六进制-转义-序列:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A character literal is one or more characters enclosed in single quotes, as in 'x' , optionally preceded by the letter L , as in L'x' . A character literal that does not begin with L is an ordinary character literal, also referred to as a narrow-character literal. An ordinary character literal that contains a single c-char has type char , with value equal to the numerical value of the encoding of the c-char in the execution character set. An ordinary character literal that contains more than one c-char is a multicharacter literal. A multicharacter literal has type int and implementation-defined value.
| 字符文字量是被单引号包围的一个或多个字符,如 'x' ,也可跟在字母 L 后面,如 L'x' 。 前面没有 L 的字符文字量是普通字符文字量,也叫做窄字符文字量。包含单个 c-字符的普通字符文字量具有类型 char , 与执行字符集中该 c-字符的编码数值相等。包含多个 c-字符的普通字符文字量是多字符文字量。多字符文字量的类型是 int ,其值由实现定义。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A character literal that begins with the letter L , such as L'x' , is a wide-character literal. A wide-character literal has type wchar_t .23) The value of a wide-character literal containing a single c-char has value equal to the numerical value of the encoding of the c-char in the execution wide-character set. The value of a wide-character literal containing multiple c-chars is implementation-defined.
| 以 L 开始的字符文字量是宽字符文字量,如 L'x' 。宽字符文字量具有类型 wchar_t 。23) 包含一个 c-字符的宽字符文字量的值与执行宽字符集中该 c-字符的编码数值相等。包含多个 c-字符的宽字符文字量的值由实现定义。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Certain nongraphic characters, the single quote ' , the double quote " , the question mark ? , and the backslash / , can be represented according to Table 5.
The double quote
| 某些非图形字符,单引号 ',双引号 ",问号 ?,以及反斜线 /,按照表格 5 来说明。
双引号
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The escape / ooo consists of the backslash followed by one, two, or three octal digits that are taken to specify the value of the desired character. The escape /x hhh consists of the backslash followed by x followed by one or more hexadecimal digits that are taken to specify the value of the desired character. There is no limit to the number of digits in a hexadecimal sequence. A sequence of octal or hexadecimal digits is terminated by the first character that is not an octal digit or a hexadecimal digit, respectively. The value of a character literal is implementation-defined if it falls outside of the implementation-defined range defined for char (for ordinary literals) or wchar_t (for wide literals).
| 由反斜线后面跟着一个,两个或三个八进制数字构成的转义序列 /ooo,用以代表其所指定字符的值。由反斜线后面跟着 x 再跟着一个或多个十六进制数字构成的转义序列 /xhhh,用以代表其所指定字符的值。十六进制序列的数字个数没有限制。八进制或十六进制数字序列分别在遇到第一个不是八进制或十六进制数字的字符时结束。当字符文字量的值超过由实现定义的 char(对于普通文字量)或 wchar_t(对于宽文字量)的数值范围时,其值由实现定义。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A universal-character-name is translated to the encoding, in the execution character set, of the character named. If there is no such encoding, the universal-character-name is translated to an implementation-defined encoding. [Note: in translation phase 1, a universal-character-name is introduced whenever an actual extended character is encountered in the source text. Therefore, all extended characters are described in terms of universal-character-names. However, the actual compiler implementation may use its own native character set, so long as the same results are obtained. ]
| 统一字符名称被翻译成其命名的字符在运行字符集中的编码。如果此编码不存在,则统一字符名称被翻译成实现定义的编码。【注:在翻译阶段 1,一旦某扩展字符在源文本中出现,统一字符名称就被引入。因此,所有扩展字符都按照统一字符名称来表示。然而,只要能够产生相同结果,实际编译器实现可以使用其自己的本地字符集。】
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
23) They are intended for character sets where a character does not fit into a single byte.
| 23) 它们由不能用单个字节表达字符的字符集利用。
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PREV [lex.icon] | NEXT [lex.fcon] | 上一页 【词法.整型常量】 | 下一页 【词法.浮点常量】 |
2.13.2 - [lex.ccon] - 【词法.字符常量】
最新推荐文章于 2021-09-21 09:49:47 发布
请不要转载本文;请不要以任何形式重新出版,发布本文;请在下载本文 24 小时内将其删除;禁止将本文用于商业目的。