为什么限制为255 [英] Why 255 is the limit

查看:124
本文介绍了为什么限制为255的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多地方说:

最大字符数为255.

The maximum number of characters is 255.

其中字符是ASCII.有技术原因吗?

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

编辑:我知道ASCII由8位表示,因此有256个不同的字符.问题是为什么他们将最多字符数(重复)指定为255.

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.

推荐答案

我假设您所指的限制是一串ASCII字符的长度.

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

出现限制是由于一种优化技术,其中较小的字符串存储在第一个字节中,该字符串保留字符串的长度.由于一个字节只能容纳256个不同的值,因此,由于第一个字节保留用于存储长度,因此最大字符串长度将为255.

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.

这篇关于为什么限制为255的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆