F
Francesco S. Carta
Hi there,
when I create some less-than-trivial console program that involves some
kind of pseudo-graphic interface I resort to using the glyphs that lie
in the range [-128, -1] - the simple "char" type is signed in my
implementation.
You know, all those single/double borders, corners, crosses,
pseudo-shadow (dithered) boxes and so on.
Since those characters mess up the encoding of my files, I cannot put
them straight into the source code as char-literals, I have to hard-code
their numeric values.
I noticed that, at least on my implementation, it doesn't make any
difference if I assign a negative value to an unsigned char - the
expected glyph shows up correctly - hence I think I wouldn't have to
worry if the same code is run on an implementation where char is unsigned.
My questions:
- what assumptions (if any) can I make about the presence of those
out-of-common-range characters and their (correct) correspondence with
the codes I use to hard-code?
- assuming it is possible to, how can I ensure that my program displays
the correct "graphics" regardless of the platform / implementation it is
compiled onto?
Note: resorting to an external library that "does the stuff for me" is
not an option here, I'm asking in order to learn, not just to solve an
issue.
Thank you for your attention.
when I create some less-than-trivial console program that involves some
kind of pseudo-graphic interface I resort to using the glyphs that lie
in the range [-128, -1] - the simple "char" type is signed in my
implementation.
You know, all those single/double borders, corners, crosses,
pseudo-shadow (dithered) boxes and so on.
Since those characters mess up the encoding of my files, I cannot put
them straight into the source code as char-literals, I have to hard-code
their numeric values.
I noticed that, at least on my implementation, it doesn't make any
difference if I assign a negative value to an unsigned char - the
expected glyph shows up correctly - hence I think I wouldn't have to
worry if the same code is run on an implementation where char is unsigned.
My questions:
- what assumptions (if any) can I make about the presence of those
out-of-common-range characters and their (correct) correspondence with
the codes I use to hard-code?
- assuming it is possible to, how can I ensure that my program displays
the correct "graphics" regardless of the platform / implementation it is
compiled onto?
Note: resorting to an external library that "does the stuff for me" is
not an option here, I'm asking in order to learn, not just to solve an
issue.
Thank you for your attention.