• Advertisement
Sign in to follow this  

char question

This topic is 4346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can you rely on the range 0-127 of ascii characters being the same if it is signed or unsigned?

Share this post


Link to post
Share on other sites
Advertisement
Yes. Only Extended ASCII characters [128:255] are subject to sign issues. (is that valid english? o_O)

Share this post


Link to post
Share on other sites
Quote:
Original post by Konfusius
Yes. Only Extended ASCII characters [128:255] are subject to sign issues. (is that valid english? o_O)

yes it is. congratulations.
you'll find that most americans unlike their british counterparts don't worry about valid english. [grin]

Share this post


Link to post
Share on other sites
Isn't there supposedly some horrible system somewhere with 7 bit characters, meaning [64:127] could be negative?

Not that I care, I regularly make the probably false assumption that char is at least 8 bits.

Share this post


Link to post
Share on other sites
Quote:
Original post by smart_idiot
Isn't there supposedly some horrible system somewhere with 7 bit characters?

Not that I care, I regularly make the probably false assumption that char is at least 8 bits.


You can store the full ascii set in 7 bits (0-127), so I suppose that you could have to deal with -ve ascii chars, but very few people ever use platforms with non-8 bit chars (for game development).

Quote:
Original post by Alpha_ProgDes
Quote:
Original post by Konfusius
Yes. Only Extended ASCII characters [128:255] are subject to sign issues. (is that valid english? o_O)

yes it is. congratulations.
you'll find that most americans unlike their british counterparts don't worry about valid english. [grin]


Bah, humbug.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by smart_idiot
Isn't there supposedly some horrible system somewhere with 7 bit characters, meaning [64:127] could be negative?

Not that I care, I regularly make the probably false assumption that char is at least 8 bits.


CHAR_BIT is required to be at least 8 bits by the ISO C standard. The ISO C++ standard defines CHAR_BIT in terms of the ISO C standard. Thus, char is at least 8 bits. More directly, CHAR_MAX is required to be at least 127. (CHAR_MAX is equivalent to either SCHAR_MAX (at least 127) or UCHAR_MAX (at least 255), depending on whether char is treated as signed or unsigned.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement