0

From here, it’s clear that char can't store extended ASCII values, so we use unsigned char.

The basic ASCII values are in the range 0 to 127. The rest part of the ASCII is known as extended ASCII. Using char or signed char we cannot store the extended ASCII values. By using the unsigned char, we can store the extended part as its range is 0 to 255.

But According to this answer, after 127 characters are invalid

ASCII was and is only defined between 0 and 127. Everything above that is either invalid or needs to be in a defined encoding other than ASCII (for example ISO-8859-1).

So, what's the purpose of extended ASCII values, Why use unsigned char over char if after 127 ASCII values all characters are invalid?

Sidharth Mudgil
  • 1,293
  • 8
  • 25
  • You absolutely can store extended ascii values in a signed `char`. I don't think they're defined as having values from 128-256, they are defined as specific 8-bit patterns, whether you interpret these patterns as positive or negative doesn't matter. Also note that whilst most platforms have a signed `char`, that is not specified by the standard and it could be unsigned – Alan Birtles Jun 29 '22 at 08:16
  • 1
    I do not fully understand the question. `What is the use of extended ASCII?` To encode characters. Like any encoding. `after 127 ASCII values all characters are invalid?` after 127 characters are invalid ASCII, they are valid extended ASCII. Extended ASCII != ASCII. – KamilCuk Aug 13 '22 at 08:47
  • @KamilCuk so Extended ASCII is a different encoding data right? – Sidharth Mudgil Aug 13 '22 at 08:52
  • 3
    https://en.wikipedia.org/wiki/Extended_ASCII . It's a group (classification? something like that) of encodings that use 8-bits and have lower 127 same as ASCII.. Like ISO-8859-1 ISO8859-2 etc. You use the term "Extended ASCII" usually meaning as like "one of the encodings that are extending ASCII". – KamilCuk Aug 13 '22 at 08:54
  • @Jason While I'm not formally disputing your closure here, just bear in mind that, if you *actually* thought that the Q wasn't clear enough, then you should vote-to-close with the "Needs details or clarity" reason. Using a dupe-hammer when you really mean another reason is actually abuse of the privilege. Just saying. – Adrian Mole Aug 13 '22 at 10:03
  • @AdrianMole I agree with your point but it is also possible that a question can both be *unclear* as well as a *dupe*. This is what happened here. The question was unclear(to me) as well as i thought that it can be answered by linking it to some already existing questions. Now, i had the option to vote to close according to my understanding of what is best here. So i closed it as dupe. – Jason Aug 13 '22 at 10:12
  • @Jason Yeah. Like I said, I'm not disputing the dupes. But, my own take on using the dupe-hammer is that, if there is *any* doubt in my mind, I'll post a comment linking the "possible dupe(s)" and let others confirm/deny my idea. With great power comes great responsibility. – Adrian Mole Aug 13 '22 at 10:17
  • 1
    @AdrianMole Ok, so since you agree here that the dupes are valid and can be used here, i don't think i have to worry about anything here. I mean sometimes it happens that the user(OP) is not able to clearly write the question due to reasons like *language barrier*, *not aware of technical terms* or just *lack of experience in that domain* etc then we can point them to the right direction by linking dupes. Now, whether the dupes should be posted in the comment section or the post should be closed as dupe depends on person to person. In my case, i prefer to close the question if i've the option. – Jason Aug 13 '22 at 10:23
  • 1
    tutorialspoint is just some silly guides, don't use it. Only the standards are authoritative sources of information, and one of the reliable sources based on standards is https://en.cppreference.com – phuclv Aug 13 '22 at 10:51
  • @AdrianMole For example, [this](https://stackoverflow.com/questions/73344072/cpp-dynamically-modifying-passing-string-by-reference-but-works-when-declared-as) question when originally posted is very unclear. But still the user [Sam Varshavchik] closed it as a dupe. And this is what i was saying. In particular, we have the option to close a question according to our understanding of that question. Even when the question is unclear but still we(not all but experienced people) can still infer that the dupe is fine. Ofcourse we should still write a comment saying that the question is unclear. – Jason Aug 13 '22 at 12:09

0 Answers0