About NUL


Integer ASCII code: 0
Binary code: 0000 0000
Octal code: 0
Hexadecimal code: 00
Group: control
Seq: ^@
C/C++ notation: \0 or '\0'

Unicode symbol: , int code: 9216 (html &#9216) hex code: 2400 (html &#x2400)


Information


NULL


At first it had a function of leaving the gaps on paper tape for some edits. Time passed and later it was used for one more purpose: padding after a code that could've taken some time in order to process (e.g. a carriage return or line feed on a printing terminal). Nowadays it's frequently used as a string terminator. It is pretty convenient for the programming language C.

Let's move in to some descriptive facts of this character. So, the null character (also null terminator or null byte), or briefly NUL, is a control character with the value zero. Lots of character sets have it, including ISO/IEC 646 (or ASCII), the C0 control code, the Universal Coded Character Set (or Unicode), and EBCDIC. Practically all popular programming languages use null character in their operations.

What was the initial meaning of NUL? It's actually was like NOP— it doesn't play any role, when it is sent to a printer or a terminal, (nevertheless, some terminals display it as space, which wasn't correct). At past times, when people used electromechanical teleprinters in the role of computer output devices, one or even a couple of null characters were used in the following way. They were sent at the end of each printed line in order to let the mechanism take its time just to return to the first printing position on the next line. There is no a single hole on the character on punched tape, so a completely new tape which wasn't punched is totally filled with null characters. This way, the text could often be "inserted" at a specially kept for this space of null characters by punching the new characters into the tape, covering the nulls.

Nowadays the null character is of primer importance in C and its derivatives and in many data formats as well. There it plays a role of the reserved character which function is to show the end of a string, which is frequently called a null-terminated string. This way the string can be as long as it is needed with just the overhead of one byte. There is the alternative of storing a count is needed either a string length with a limit of 255 or an overhead of more than just one byte (you can find the other advantages/disadvantages under null-terminated string).

Representation


The commonly used representation of the null character is the escape sequence \0 in source code string literals or character constants. In an overwhelming amount of languages (such as C, from which we have started this article), null is represented not by an individual escape sequence, but an octal escape sequence, which has a single octal digit 0; in sequence of digits, it is impossible for \0 to be followed by any of the digits 0 through 7; if it happens, it is treated as the beginning of a longer octal escape sequence. There are some other escape sequences that are used in different languages, for example \000, \x00, \z, or the Unicode representation \u0000. allows to place a null in it URL with the percent code %00.

If a null character is represented, there is no guarantee that the resulting string will be properly interpreted. It happens because lots of programs will consider the null as the end of the string. There is such a term like null byte injection. An ability to type in (in case of unchecked user input) is actually a weak point. This can lead to security exploits.

The null character in caret notation ha the following representation: ^@. There are some keyboards, which allow entering a null character by holding down Ctrl and pressing @ (which usually requires also holding ⇧ Shift and pressing another key such as 2 or P).

The null character in documentation may have the representation of a single-em-width symbol, including the letters "NUL". However, this happen not so often. Unicode has a character with the appropriate glyph for visual representation of the null character, "symbol for null", U+2400 (␀) It`s important not to confuse it with the real null character, U+0000.

Encoding


In all character which are used today, the null character possesses a zero code point value. This is translated to a single code unit with a zero value in overwhelming amount of all the encodings. Let's see the example. In UTF-8 it is a single zero byte. Nevertheless, in Modified UTF-8 the null character is encoded as two bytes: 0xC0, 0x80. This lets the byte with the value of zero to be used as a string terminator, because currently it's not used for any character.


Hash


input value base type output hash
NUL char MD5 93b885adfe0da089cdf634904fd59f71
NUL char SHA1 5ba93c9db0cff93f52b521d7420e43f6eda2784f
0 dec MD5 cfcd208495d565ef66e7dff9f98764da
0 dec SHA1 b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
00000000 bin MD5 dd4b21e9ef71e1291183a46b913ae6f2
00000000 bin SHA1 70352f41061eda4ff3c322094af068ba70c3b38b
0000 0000 bin MD5 e7e9990cc7667ac4ca751fd99679a592
0000 0000 bin SHA1 6ceff7e8b0d1005f2454803ea18e4fab87309ee5
0 oct MD5 cfcd208495d565ef66e7dff9f98764da
0 oct SHA1 b6589fc6ab0dc82cf12099d1c2d40ab994e8410c
00 hex MD5 b4b147bc522828731f1a016bfa72c073
00 hex SHA1 fb96549631c835eb239cd614cc6b5cb7d295121a
0x00 hex MD5 83d6ad7f1c5045ab8112a8411c8091f2
0x00 hex SHA1 58783889d2d13862937fdf2c468568721090fdb4
Back to ASCII table

 2018 © Dmytro Koshovyi. Ukraine, Mykolayiv.