C++ Primer Plus 第 6 章第 3 章 - 关于如何使用通用字符名称
chapter 3 of C++ Primer Plus 6th - about how to use universal character name
c++ primer plus 6th原文如下:
Using universal character names is similar to using escape sequences.A universal character name begins either with \u or \U.The \u form is followed by 8 hexadecimal digits,
and the \U form by 16 hexadecimal digits.These digits represent the ISO 10646 code
point for the character. (ISO 10646 is an international standard under development that
provides numeric codes for a wide range of characters. See “Unicode and ISO 10646,”
later in this chapter.)
但是和我之前的观点有冲突,所以在python3文档中找到了如下描述:
In Python source code, specific Unicode code points can be written using the \u escape sequence, which is followed by four hex digits giving the code point. The \U escape sequence is similar, but expects eight hex digits, not four.
所以我的问题是,当我使用 \u 形式时,它应该是四个十六进制位还是八位?
\u
之后的四个十六进制数字,\U
之后的八个十六进制数字。来自 C++ 标准:
[lex.charset]/2 The universal-character-name construct provides a way to name other characters.
hex-quad:
hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit
universal-character-name:
\u hex-quad
\U hex-quad hex-quad
c++ primer plus 6th原文如下:
Using universal character names is similar to using escape sequences.A universal character name begins either with \u or \U.The \u form is followed by 8 hexadecimal digits, and the \U form by 16 hexadecimal digits.These digits represent the ISO 10646 code point for the character. (ISO 10646 is an international standard under development that provides numeric codes for a wide range of characters. See “Unicode and ISO 10646,” later in this chapter.)
但是和我之前的观点有冲突,所以在python3文档中找到了如下描述:
In Python source code, specific Unicode code points can be written using the \u escape sequence, which is followed by four hex digits giving the code point. The \U escape sequence is similar, but expects eight hex digits, not four.
所以我的问题是,当我使用 \u 形式时,它应该是四个十六进制位还是八位?
\u
之后的四个十六进制数字,\U
之后的八个十六进制数字。来自 C++ 标准:
[lex.charset]/2 The universal-character-name construct provides a way to name other characters.
hex-quad: hexadecimal-digit hexadecimal-digit hexadecimal-digit hexadecimal-digit universal-character-name: \u hex-quad \U hex-quad hex-quad