[half OT] About the not-in-common range of signed and unsigned char

[half OT] About the not-in-common range of signed and unsigned char

Post by Francesco » Thu, 15 Jul 2010 08:01:47


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.

--
FSC - http://www.yqcomputer.com/
http://www.yqcomputer.com/ - http://www.yqcomputer.com/
 
 
 

[half OT] About the not-in-common range of signed and unsigned char

Post by Victor Baz » Thu, 15 Jul 2010 08:13:13


You need to ask this in the newsgroup for your OS and/or your terminal
because those things are hardware- and platform-specific. Those
characters are not part of the basic character set, C++ knows nothing
about them.


There is no way.


<shrug> Whatever.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

 
 
 

[half OT] About the not-in-common range of signed and unsigned char

Post by Francesco » Thu, 15 Jul 2010 08:22:03


I'm sorry if my post disturbed you: I explicitly marked it as "[half
OT]" and I posted it here for a reason, which should be evident.

Nonetheless, thank you for your reply, Victor - that's just what I was
looking for: the confirmation that I cannot portably resort to those
graphics, so that I'll avoid struggling for something that isn't
achievable - this is "learning", for me.

--
FSC - http://www.yqcomputer.com/
http://www.yqcomputer.com/ - http://www.yqcomputer.com/
 
 
 

[half OT] About the not-in-common range of signed and unsigned char

Post by Victor Baz » Thu, 15 Jul 2010 08:48:07


It didn't disturb me. I am sorry you thought I did (why did you think
that?). And the only reason evident to me is that you asked a valid
question on C++. What other reason would one need?


Well, you seemed to post when you already knew the answer (although I
can still be mistaken). You either need to use somebody else's library
(which will represent an abstraction layer for you, and behind the
scenes its code is platform-specific, regardless what language it is
implemented in) or implement that functionality yourself, essentially
reproducing the same library.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 
 
 

[half OT] About the not-in-common range of signed and unsigned char

Post by Francesco » Thu, 15 Jul 2010 09:24:30

ictor Bazarov < XXXX@XXXXX.COM >, on 13/07/2010 19:48:07, wrote:


Your last line above ("<shrug> Whatever.") made me think that the whole
post disturbed or at least annoyed you. I'm glad to discover that I
misinterpreted your post :-)


That was a "combined" reply, relative to my misinterpretation of your
post /and/ to the fact that you pointed me to another group. The reason
for posting it here is exactly the one you noted: it's about C++ - even
though it was likely to be a platform-specific issue - "half OT", as I
said ;-)


Technically no, I didn't "know" the answer, I just suspected it, hence I
asked for confirmation (although I didn't express my question as such).

Although it is true that I could have just relied on my understanding of
the standard, I was also hoping to get a "real life" reply on the lines
of "on windows and linux you're pretty much safe assuming those
characters [are|aren't] available and [have|haven't] the same values,
I've tried [this] and [that], and [that other] gave me problems, YMMV,
do some tests".

[ besides: the threads here happen to see people dropping in with
not-strictly-related comments which are precious, at times, because they
lead me to investigate new things - posting stuff like this is (also)
another chance to see those kind of "lateral" follow-ups ]

Thank you for your clarification and for the further details.

--
FSC - http://userscripts.org/scripts/show/59948
http://fscode.altervista.org - http://sardinias.com