Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why 255 is the limit

I've seen lots of places say:

The maximum number of characters is 255.

where characters are ASCII. Is there a technical reason for that?

EDIT: I know ASCII is represented by 8 bits and so there're 256 different characters. The question is why do they specify the maximum NUMBER of characters (with duplicates) is 255.

like image 471
Zhi Avatar asked Oct 04 '14 21:10

Zhi


People also ask

Which field type has a limit of 255 characters?

The Text field is one of the most generic and common data entry fields used to capture text type data—letters, numbers, and symbols. Text fields hold up to 255 characters in a single line.

How many bits is 255 characters?

The original 16-bit resource format represented strings as null-terminated sequences of bytes, so in theory they could have been arbitrarily large. However, 16-bit string resources were limited to 255 characters because they used a byte count for string length.

What character is ASCII 255?

The ASCII character 255 is actually a non-breaking space, or NBSP!

What does max 250 characters mean?

Answer: 250 characters is between 35 words and 63 words with spaces included in the character count. If spaces are not included in the character count, then 250 characters is between 41 words and 84 words.


1 Answers

I assume the limit you're referring to is on the length of a string of ASCII characters.

The limit occurs due to an optimization technique where smaller strings are stored with the first byte holding the length of the string. Since a byte can only hold 256 different values, the maximum string length would be 255 since the first byte was reserved for storing the length.

Some older database systems and programming languages therefore had this restriction on their native string types.

like image 174
Silveri Avatar answered Feb 07 '23 22:02

Silveri