In C, is it possible to force an unsigned char to print as a hex, not with %x, but in the little square box that displays the four hex numbers, but only takes up one character, for example 轩
?
Asked
Active
Viewed 221 times
-4

gmoss
- 1,019
- 5
- 17
-
2"in the little square box that displays the four hex numbers, but only takes up one character"...what does that mean? What "little square box" are you referring to? And no, the example does not help - how is that related to "four hex numbers"? – kaylum Dec 21 '15 at 01:02
-
Well, the "little box" in the example I gave has four hex numbers, "8F" in the top row and "69" in the bottom row. Each one is a byte, so there are two bytes in there. For example, if you do `unsigned char c=0x1e; printf("%c",c);` the result will be such a box with "00" in the top row and "1E" in the bottom row. I want to force printf to do this with any unsigned char I throw at it. – gmoss Dec 21 '15 at 01:06
-
@kaylum some output devices , when faced with a character for which there is no glyph in the current font, will create a glyph consisting of a square box containing the hex digits of the character code – M.M Dec 21 '15 at 01:27
-
1@gmoss in `for example 轩` I see a kanji character ... – M.M Dec 21 '15 at 01:27
1 Answers
2
No, it is not possible.
This is not related to C, but to the font your terminal uses. C outputs characters as bytes; your terminal is responsible for choosing how to display them as pixels. (You might as well ask how to make the text italic.)

user253751
- 57,427
- 7
- 48
- 90