Convert u03C0 or u2026C to char?

225 Views Asked by At

I wanted to convert a ascii to a char. If that is what I think.

I want to convert something like u03C0 to the actual symbol, which is PI.

Can this be done with control characters too? Like u206C?

Put a control character in a char or a string. Can I do this?

2

There are 2 best solutions below

1
On

You can convert the hex string to a long and to a char form there:

char c = Convert.ToChar(Convert.ToInt64("03C0",16))

You can strip the u however you like - using Replace, Substring, etc.

1
On

you can do it like this if you want:

char c = '\u206C';

or

string s = "\u206C";

But if you try to display it, you won't see anything. It's not a visible character.