MSDN.WhiteKnight - Stack Overflow answers
Ответ на "Что такое `\U`?"
Answer 1110040
Информация в документации абсолютно правильна. Синтаксис
\Udddddddd
просто включает в строковую константу символ Юникод с кодом dddddddd. Этот символ может быть суррогатной парой и занимать две кодовые единицы UTF-16, но может быть также и обычным символом, занимающим одну кодовую единицу.7.4.2 Unicode character escape sequences
A Unicode escape sequence represents a Unicode code point. Unicode escape sequences are processed in identifiers (§7.4.3), character literals (§7.4.5.5), and regular string literals (§7.4.5.6). A Unicode escape sequence is not processed in any other location (for example, to form an operator, punctuator, or keyword).
unicode-escape-sequence:: \u hex-digit hex-digit hex-digit hex-digit \U hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit
A Unicode character escape sequence represents the single Unicode code point formed by the hexadecimal number following the “\u” or “\U” characters. Since C# uses a 16-bit encoding of Unicode code points in character and string values, a Unicode code point in the range U+10000 to U+10FFFF is represented using two Unicode surrogate code units. Unicode code points above U+FFFF are not permitted in character literals. Unicode code points above U+10FFFF are invalid and are not supported.
В первом случае значение кодовой позиции больше U+10000, поэтому оно представлено двумя кодовыми единицами. Во втором случае - меньше, поэтому одной.
Другими словами, запись
\U0000FADE
эквивалентна\uFADE
, а не\u0000\uFADE
, как может показаться на первый взгляд (последняя действительно состоит из двух кодовых единиц).
Content is retrieved from StackExchange API.
Auto-generated by ruso-archive tools.