ASCII NULL字符 [英] ASCII NULL character

查看:248
本文介绍了ASCII NULL字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASCII仅用于字符. NULL 不是字符,为什么 NULL 具有ASCII值0

ASCII is only for character. NULL is not a character, then why NULL has a ASCII value 0

推荐答案

ASCII仅适用于[可打印]字符

ASCII is only for [printable] character[s]

不太准确:除了可打印字符外,ASCII还包括许多 control 字符.

Not quite: in addition to printable characters, ASCII also includes a number of control characters.

ASCII码0(NUL)是这样的控制字符之一.

ASCII code 0 (NUL) is one such control character.

引用维基百科:

ASCII保留用于控制字符的前32个代码(十进制数字0-31):最初旨在不表示可打印信息,而是用于控制使用ASCII或提供元字符的控制设备(例如打印机)的代码.有关数据流的信息,例如存储在磁带上的数据流.例如,字符10代表换行"功能(使打印机前进),字符8代表退格".

ASCII reserves the first 32 codes (numbers 0-31 decimal) for control characters: codes originally intended not to represent printable information, but rather to control devices (such as printers) that make use of ASCII, or to provide meta-information about data streams such as those stored on magnetic tape. For example, character 10 represents the "line feed" function (which causes a printer to advance its paper), and character 8 represents "backspace".

这几天,NUL字符最常用于表示 C .但是,它的原始目的有所不同:

These days, the NUL character is most frequently used to signify the end of a character string in C. Its original purpose, however, was different:

此字符的原始含义就像NOP一样-当发送到打印机或终端时,它什么都不做(但是,某些终端错误地将其显示为空格).当机电式电传打印机用作计算机输出设备时,在每个印刷行的末尾发送一个或多个空字符,以使该机制有时间返回下一行的第一个印刷位置.在打孔的磁带上,该字符完全没有孔表示,因此,新的未打孔的磁带最初填充有空字符,并且通常可以通过将新字符打孔到磁带上,从而在保留的空字符空间中插入"文本空值.

The original meaning of this character was like NOP -- when sent to a printer or a terminal, it does nothing (some terminals, however, incorrectly display it as space). When electromechanical teleprinters were used as computer output devices, one or more null characters were sent at the end of each printed line to allow time for the mechanism to return to the first printing position on the next line. On punched tape, the character is represented with no holes at all, so a new unpunched tape is initially filled with null characters, and often text could be "inserted" at a reserved space of null characters by punching the new characters into the tape over the nulls.

这篇关于ASCII NULL字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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