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");
Your problem is that you copied
\U00HHHHHH
from the documentation page Strings (C# Programming Guide): String Escape Sequences:But
\U00HHHHHH
is not itself a valid UTF-32 escape sequence -- it's a mask where eachH
indicates where a Hex character must be typed. The reason it's not valid is that hexadecimal numbers consist of the digits 0-9 and the letters A–F or a–f -- andH
is not one of these characters. And the literal mentioned in comments,"\U001effff"
, does not work because it falls outside the range the range of valid UTF-32 characters values specified immediately thereafter in the docs:The c# compiler actually checks to see if the specified UTF-32 character is valid according to these rules:
See https://dotnetfiddle.net/KezdTG.
As an aside, to properly display Unicode characters in the Windows console, see How to write Unicode characters to the console?.