Null character

Null character

The null character (also null terminator), abbreviated NUL, is a control character with the value zero.[1] [2] It is present in many character sets, including ISO/IEC 646 (or ASCII), the C0 control code, the Universal Character Set (or Unicode), and EBCDIC. It is available in nearly all mainstream programming languages.[3]

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.[citation needed] 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.

Today the character has much more significance in C and its derivatives and in many data formats, where it serves as a reserved character used to signify the end of a string,[4] often called a null-terminated string or "ASCIIZ" string.[5] This allows the string to be any length with only the overhead of one byte; the alternative of storing a count requires either a string length limit of 255 or an overhead of more than one byte (there are other advantages/disadvantages described under null-terminated string).



The null character is often represented as the escape sequence \0 in source code string literals or character constants.[6] 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.[7] 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.[8]

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.[citation needed]

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.

See also

  • Control characters


  1. ^ ASCII format for Network Interchange. sec. 5.2. RFC 20. "NUL (Null): The all-zeros character which may serve to accomplish time fill and media fill." 
  2. ^ "The set of control characters of the ISO 646" (PDF). Secretariat ISO/TC 97/SC 2. 1975-12-01. p. 4.4. "Position: 0/0, Name: Null, Abbreviation: Nul" 
  3. ^ "A byte with all bits set to 0, called the null character, shall exist in the basic execution character set; it is used to terminate a character string literal." — ANSI/ISO 9899:1990 (the ANSI C standard), section 5.2.1
  4. ^ "A string is a contiguous sequence of characters terminated by and including the first null character" — ANSI/ISO 9899:1990 (the ANSI C standard), section 7.1.1
  5. ^ "A null-terminated byte string, or NTBS, is a character sequence whose highest-addressed element with defined content has the value zero (the terminating null character)" — ISO/IEC 14882 (the ISO C++ standard), section
  6. ^ Kernighan and Ritchie, C, p. 38
  7. ^ In YAML this combination is a separate escape sequence.
  8. ^ Null Byte Injection WASC Threat Classification Null Byte Attack section.

External links

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • null character — tarpo simbolis statusas T sritis automatika atitikmenys: angl. blank character; gap character; null character; space character vok. Leerzeichen, n; Nullzeichen, n rus. знак пробела, m; символ пробела, m pranc. caractère blanc, m …   Automatikos terminų žodynas

  • null character — The ASCII character 0, or CTRL &. This character usually will not be printed on the screen. It was originally used when communications programs were slower and could not receive information as fast as it was sent, so BBS programs would send these …   Dictionary of telecommunications

  • null character — …   Useful english dictionary

  • Null — may refer to: Contents 1 In computing 2 In art 3 In mathematics 4 In science 5 People …   Wikipedia

  • Null (computer programming) — Null has several meanings in computer programming.;Null pointer or null reference * Null is a special pointer value (or other kind of object reference) used to signify that a pointer intentionally does not point to (or refer to) an object. Such a …   Wikipedia

  • Null Object pattern — Null object redirects here. For the concept in category theory, see Initial object. In object oriented computer programming, a Null Object is an object with defined neutral ( null ) behavior. The Null Object design pattern describes the uses of… …   Wikipedia

  • Null symbol — may refer to: Null character, U+0000 ␀, U+2400 symbol for null , a single character glyph NUL Null sign ∅ for the empty set Null (SQL) ω in database theory λ, Λ, or ε, for the empty string See also Null (disambiguation) …   Wikipedia

  • Null (desambiguación) — Null puede referirse En programación a null, el puntero nulo. En base de datos a null, el valor nulo. El carácter ASCII de código 0 es conocido como null character o carácter nulo, escrito también NUL o nil . En Venezuela, es usado para insultar… …   Wikipedia Español

  • Null (SQL) — The Greek lowercase omega (ω) character is used to represent Null in database theory. Null is a special marker used in Structured Query Language (SQL) to indicate that a data value does not exist in the database. Introduced by the creator of the… …   Wikipedia

  • Null-terminated string — In computer programming, a null terminated string is a character string stored as an array containing the characters and terminated with a null character ( , called NUL in ASCII). Alternative names are C string, which refers to the C… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”