Currently I am trying to fix some formatting in my application. I am trying to subscript a string
and append it to a normal string
- the same way you can do it in MS word. I already tried this (as supposed here and here):
string temp = "NormalText";
foreach( char t in "SubscriptedText".ToCharArray())
temp += "\x208" + t;
MessageBox.Show(temp);
Output:
NormalTextȈSȈuȈbȈsȈcȈrȈiȈpȈtȈeȈdȈTȈeȈxȈt
But, as I noted afterwards it is the font who has to support the unicode definitions. And on the internet there doesn't seem to be a font who supports all letters in supscripted format.
So, is there a way to format my text in order to subscript the second half of it? Maybe a simple function I am missing? Or is this just not possible and I have to align my subscripted text on my own?
EDIT Also tried this:
string temp = "NormalText";
foreach( char t in "SubscriptedText".ToCharArray())
temp += "\x208" + (int)t;
MessageBox.Show(temp);
But (of course) this didn't work out at all. I've got my output looking like this:
NormalTextȈ84Ȉ105Ȉ101Ȉ102Ȉ101Ȉ114Ȉ84Ȉ101Ȉ120Ȉ11
C#
doesn't have subscript or superscript. That's an issue for whatever is displaying the string (and aMessageBox
isn't going to do it). There are a limited subset of superscript and subscript characters in a unicode block but there isn't a general way to make a block of arbitrary characters in a string super or sub script.MessageBox
that can handle sub and super script, then you will need to create your own that can, for example, display rich text or HTML or some format of your own.\x2081
would give you a subscript1
, but it's not telling you that adding\x208
before a character makes the next character subscript.WPF