Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 256 means for 128 unique characters in ascii table

Tags:

ascii

If I need to check a string has unique characters, I understand if we are considering characters in Ascii table, then there will 128 of them.

However, why do we need to make a boolean array of size 256 to hold 128 characters to check if element existed at least once in a string? Shouldn't a boolean array of size 128 sufficient?

Here's a quote from from the book "Cracking the Coding Interview":

if (str.length() > 128) return false; boolean[] char_set = new boolean[256]; //which is strange since it clearly says over 128 its false 

.....

like image 973
Lydia Avatar asked Dec 28 '14 18:12

Lydia


People also ask

Why is ASCII limited 256 characters?

The 128 or 256 character limits of ASCII and Extended ASCII limits the number of character sets that can be held. Representing the character sets for several different language structures is not possible in ASCII, there are just not enough available characters.

What is the ASCII value of 128?

2) While keep press "Alt", on your keyboard type the number "128", which is the number of the letter or symbol "Ç" in ASCII table.

What is the name give to the character set with 256 or more characters?

ASCII is a 7-bit code - one bit (binary digit) is a single switch that can be on or off, zero or one. Character sets used today in the US are generally 8-bit sets with 256 different characters, effectively doubling the ASCII set. One bit can have 2 possible states.


2 Answers

Basically, we use only 128 total character which is used mostly during program. But total number of Character in ASCII table is 256 (0 to 255). 0 to 31(total 32 character ) is called as ASCII control characters (character code 0-31). 32 to 127 character is called as ASCII printable characters (character code 32-127). 128 to 255 is called as The extended ASCII codes (character code 128-255).

check reference: http://www.ascii-code.com/

Most of the extended ASCII character isn't present in the QWERTY (ENGLISH) keyboard, so this is the reason, author took 128 total character in that example in "Cracking the coding interview" book.

like image 173
MOHIT M SHARMA Avatar answered Sep 21 '22 02:09

MOHIT M SHARMA


No, there are 256 ASCII characters. This includes standard ASCII characters(0-127) and Extended ASCII characters(128-255).

For More Info. Please refer to: http://www.flexcomm.com/library/ASCII256.htm

like image 44
ABU ABDULLAH JAVEED ASHRAF Avatar answered Sep 24 '22 02:09

ABU ABDULLAH JAVEED ASHRAF