Home > Enterprise >  assigning a very big hexadecimal to a char through \u or \x
assigning a very big hexadecimal to a char through \u or \x

Time:09-05

char k = '\u103BD';

I get a compile time error.
I want to put the following char in my char k but it seems that the escape sequence will not accept more than 4 digits.
What should I do in this case? enter image description here

CodePudding user response:

Character char is two bytes value, that's why it can be within [\u0000..\uFFFF] range only. If you are looking for values beyond \uFFFF, please note, that it should be represented as two characters construction, e.g. string:

string result = "\U000103BD"; // note Capital U, 8 hex digits

Console.Write(result);

Output:

           
  • Related