0

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®.

  • The code you posted isn't valid C#. Your problem description is not useful. Please edit your question to improve it, so that it has a [mcve], along with a clear and detailed explanation of what that code does and how that's different from what you want, as well as an explanation of what you've done to try to fix the problem, and what _specifically_ you need help with. – Peter Duniho Oct 19 '20 at 09:24
  • 1
    why don't you simply use the unicode symbol? C# supports unicode... i.e. `Console.WriteLine("Shibu®");` just works out of the box. – Markus Dresch Oct 19 '20 at 09:24

1 Answers1

1

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.

Pac0
  • 21,465
  • 8
  • 65
  • 74
  • while this likely addresses the string concatenation issue, I don't see how this solves the superscript part of the question. In particular, while the character is rendered as superscript in some fonts, it is not itself necessarily a superscript character. – Peter Duniho Oct 19 '20 at 09:25
  • @PeterDuniho It doesn't. But it's not possible IMO. I'll add a remrak about this. – Pac0 Oct 19 '20 at 09:29