Representation
The null character is often represented as the escape sequence \0
in source code string literals or character constants. In many languages (such as C, which introduced this notation), this is not a separate escape sequence, but an octal escape sequence with a single octal digit of 0; as a consequence, \0
must not be followed by any of the digits 0
through 7
; otherwise it is interpreted as the start of a longer octal escape sequence. Other escape sequences that are found in use in various languages are \000
, \x00
, the Unicode representation \u0000
, or \z
. A null character can be placed in a URL with %00
, which (in case of unchecked user input) creates a vulnerability known as null byte injection and can lead to security exploits.
In caret notation the null character is ^@
. On some keyboards, one can enter a null character by holding down Ctrl and pressing @ (which usually requires also holding ⇧ Shift and pressing another key such as 2 or P). It is also common to be able to type a null with Ctrl2 or Ctrlspace.
In documentation the null character is sometimes represented as a single-em-width symbol containing the letters "NUL". In Unicode, there is a character with a corresponding glyph for visual representation of the null character, "symbol for null", U+2400 (␀)—not to be confused with the actual null character, U+0000.
Read more about this topic: Null Character