Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Null character
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Representation == Since the null character is not a [[printable character]] representing it requires special notation in [[source code]]. In a [[string literal]], the null character is often represented as the [[escape sequence]] <code>\0</code> (for example, <code>"abc\0def"</code>). Similar notation is often used for a character literal (i.e. <code>'\0'</code>) although that is often equivalent to the numeric literal for zero (<code>0</code>).<ref name="KandR38">Kernighan and Ritchie, ''C'', p. 38: "The character constant '\0' represents the character with value zero, the null character. '\0' is often written instead of 0 to emphasize the character nature of some expression, but the numeric value is just 0."</ref> In many languages ([[Escape sequences in C|such as C]], which introduced this notation), this is not a separate escape sequence, but an octal escape sequence with a single [[octal]] digit 0; as a consequence, <code>\0</code> must not be followed by any of the digits <code>0</code> through <code>7</code>; otherwise it is interpreted as the start of a longer octal escape sequence.<ref>In [[YAML]] this combination is a [http://www.yaml.org/spec/1.2/spec.html#id2776092 separate escape sequence].</ref> Other escape sequences that are found in use in various languages are <code>\000</code>, <code>\x00</code>, <code>\z</code>, or <code>\u0000</code>. A null character can be placed in a [[URL]] with the [[Percent encoding|percent code]] <code>%00</code>. 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 of [[unchecked user input]]) creates a [[vulnerability (computing)|vulnerability]] known as '''null byte injection''' and can lead to security exploits.<ref>[http://projects.webappsec.org/Null-Byte-Injection Null Byte Injection] WASC Threat Classification Null Byte Attack section.</ref> In [[software documentation]], the null character is often represented with the text '''NUL''' (or '''NULL''' although that may mean the [[null pointer]]). In [[Unicode]], there is a character for this: {{unichar|2400}}. In [[caret notation]] the null character is <code>^@</code>. On some keyboards, one can enter a null character by holding down {{keypress|Ctrl}} and pressing {{keypress|@}} (on US layouts just {{keypress|Ctrl|2}} will often work, there being no need for {{keypress|Shift}} to get the @ sign).
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)