Thenull character is acontrol character with the valuezero.[1][2][3][4][5] Manycharacter sets include acode point for a null character – includingUnicode (Universal Coded Character Set),ASCII (ISO/IEC 646),Baudot,ITA2 codes, theC0 control code, andEBCDIC. In modern character sets, the null character has a code point value of zero which is generally translated to a single code unit with a zero value. For instance, inUTF-8, it is a single, zero byte.
Originally, its meaning was likeNOP – when sent to aprinter or aterminal, it had no effect (although some terminals incorrectly displayed it asspace). When electromechanicalteleprinters 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.[citation needed] Onpunched 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.
Anull-terminated string is a commonly used data structure in theC programming language, its many derivative languages and other programming contexts that uses a null character to indicate the end of astring.[6][7] This design allows a string to be any length at the cost of only one extra character of memory. The common competing design for a string stores the length of the string as anintegerdata type, but this limits the size of the string to the range of the integer (for example, 255 for a byte).
Forbyte storage, the null character can be called anull byte.
Since the null character is not aprintable character, representing it requires special notation insource code.
In astring literal, the null character is often represented as theescape sequence\0 (for example,"abc\0def"). Similar notation is often used for a character literal (i.e.'\0') although that is often equivalent to the numeric literal for zero (0).[8] In many languages (such as C, which introduced this notation), this is not a separate escape sequence, but an octal escape sequence with a singleoctal digit 0; as a consequence,\0 must not be followed by any of the digits0 through7 because in that case it will be interpreted as the start of a longer octal escape sequence.[9] Other escape sequences that are found in use in various languages are\000,\x00,\z, or\u0000.
A null character can be placed in aURL with thepercent code%00.
The ability to represent a null character does not always mean the resulting string will be correctly interpreted, as many programs will consider the null to be the end of the string. Thus, the ability to type it (in case ofunchecked user input) creates avulnerability known asnull byte injection and can lead to security exploits.[10]
Insoftware documentation, the null character is often represented with the textNUL (orNULL although that may mean thenull pointer). InUnicode, there is a character for this:U+2400 ␀SYMBOL FOR NULL.
Incaret notation the null character is^@. On some keyboards, one can enter a null character by holding downCtrl and pressing@ (on US layouts justCtrl+2 will often work, there being no need for⇧ Shift to get the @ sign).
NUL (Null): The all-zeros character which may serve to accomplish time fill and media fill.
Position: 0/0, Name: Null, Abbreviation: Nul
Anull-terminated byte string, or NTBS, is a character sequence whose highest-addressed element with defined content has the value zero (theterminating null character); no other element in the sequence has the value zero.