Home > Blockchain >  The \U Escape Sequence in C#
The \U Escape Sequence in C#

Time:03-20

I am experimenting with the Escape sequences and can not really use the \U sequence (UTF-32) It does not compile as it can not recognize the sequence for some reason. It recognizes it as UTF-16.

Could you please help me?

Console.WriteLine("\U00HHHHHH");

enter image description here

enter image description here

CodePudding user response:

Your problem is that you copied \U00HHHHHH from the documentation page enter image description here

But \U00HHHHHH is not itself a valid UTF-32 escape sequence -- it's a mask where each H indicates where a Hex character must be typed. The reason it's not valid is that, despite being in the required format, 0xHHHHH (as a hexadecimal number) is numerically outside the range of valid UTF-32 characters specified immediately thereafter in the docs:

(range: 000000 - 10FFFF; example: \U0001F47D = "

  • Related