Not able use superscript in C#

158 Views Asked by At

I want to display the String with superscript like Shibu® using C#. Unicode of ®:- U+000AE

Here is the code:-

String s = "Shibu";
Console.write(s.join("\xBU+000AE", s));

I am not getting proper output like Shibu®.

1

There are 1 best solutions below

2
On

You need to concatenate those strings, string.Join is for joining several strings together with a special one repeated in between.

Also, representation of unicode characters is done with \uXXXX where XXXX is the hexadecimal code point value.

string s = "Shibu";
Console.WriteLine(s + "\u00AE");

Or simply

string s = "Shibu\u00AE";
Console.WriteLine(s);

Also, you can directly write unicode characters; C# strings are unicode.

string s = "Shibu®";
Console.WriteLine(s);

This does not, however, set the character as "superscript" in the unicode or font meaning of term. I'm not sure that is possible with native C# strings, you need to cope with the existing basic unicode characters.

For fancier, use a visual rich textbox control, or a WPF control, that allow you to set font options.