viraj
viraj

Reputation: 1814

Unicode character for superscript shows a square box: ࠚ

Using the following code to create a Unicode string:

wchar_t HELLO[20];
wsprintf(HELLO, TEXT("%c"), 0x2074);

When I display this onto a Win32 Control like a Text box or a button it gets mapped to a [] Square. How do I fix this ? I tried compiling with both Eclipse(MinGW) and Microsoft Visual C++ (2010). Also, UNICODE is defined at the top

Edit:

I think it might be something to do with my system, because when I visit: http://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts some of the unicode characters don't appear.

Upvotes: 1

Views: 3071

Answers (2)

Matteo Italia
Matteo Italia

Reputation: 126867

The characters you are getting from Wikipedia are expressed in hexadecimal, so your code should be:

wchar_t HELLO[20];
wsprintf(HELLO, TEXT("%c"), (wchar_t)0x2074);  // or TEXT('\x2074')

If it still doesn't work, it's a font problem; if you need a pan-Unicode font, it seems that Code2000 is one of the most complete out there.


Funny fact: the character that has the decimal code 2074 (i.e. hex 81a) seems to actually be a box (or it's such a strange beast that even the image outline at FileFormat.Info is wrong). :)

For the curious ones: it turns out that 0x081a is this thing:

enter image description here

Upvotes: 2

David Heffernan
David Heffernan

Reputation: 613302

The font you are using does not contain a glyph for that character. You will likely need to install some new fonts to overcome this deficiency.

The character you have picked out is 'SAMARITAN MODIFIER LETTER EPENTHETIC YUT' (U+081A). Perhaps you were after U+2074, i.e. 'SUPERSCRIPT FOUR' (U+2074). You need hex for that: 0x2074.

Note you changed the question to read 0x2074 but the original version read 2074. Either way, if you see a box that indicates your font is missing that glyph.

Upvotes: 7

Related Questions