control character whose bits are all 0

The null character is a control character with the value zero. Many character sets include a code point for a null character โ€“ including Unicode (Universal Coded Character Set), ASCII (ISO/IEC 646), โ€ฆ Wikipedia
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ Null_character
Null character - Wikipedia
1 week ago - The null character is a control character with the value zero. Many character sets include a code point for a null character โ€“ including Unicode (Universal Coded Character Set), ASCII (ISO/IEC 646), Baudot, ITA2 codes, the C0 control code, and EBCDIC. In modern character sets, the null character ...
๐ŸŒ
ASCII Code
ascii-code.com โ€บ character โ€บ โ€
Null character - ASCII Code
In some cases, it is referred to as the NUL character. Here are some key details: In ASCII and Unicode, the null character is defined to be U+0000, meaning it is represented in Unicode as the number 0.
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ null character '\0' & null terminated strings
r/C_Programming on Reddit: Null character '\0' & null terminated strings
December 25, 2022 -

Hello everyone!
In C, strings (character arrays) are terminated by null character '\0' - character with value zero.
In ASCII, the NUL control code has value 0 (0x00). Now, if we were working in different character set (say the machine's character set wouldn't be ASCII but different one), should the strings be terminated by NUL in that character set, or by a character whose value is zero?

For example, if the machine's character set would be UTF-16, the in C, byte would be 16bits and strings would be terminated by \0 character with value 0x00 00, which is also NUL in UTF-16.
But, what if the machine's character set would be modified UTF-8 (or UTF-7, ...). Then, according to Wikipedia, the null character is encoded as two bytes 0xC0, 0x80. How would be strings terminated in that case? By the byte with value 0 or by the null character.

I guess my question could be rephrased as: Are null terminated strings terminated by the NUL character (which in that character set might be represented by a nonzero value) or by a character whose value is zero (which in that character set might not represent the NUL character).

Thank you all very much and I'm sorry for all mistakes and errors as english is not my first language.

Thanks again.

Top answer
1 of 3
31
should the strings be terminated by NUL in that character set, or by a character whose value is zero? The character '\0' is guaranteed to be a byte with all bits zero, and to have a numeric value equal to zero. A string in C always ends with this character. Then, according to Wikipedia, the null character is encoded as two bytes 0xC0, 0x80. No, in standard UTF-8 the code point with value zero is encoded in a single zero byte. You may have been reading something about "modified UTF-8", which appears to be a rather Java-centric external encoding for strings. It deliberately uses an "overlong" encoding of Java '\u0000' so that the resulting byte sequence does not contain a zero byte. One reason for this is because the length of strings in Java is not defined by use of a terminating character โ€” a Java string can contain arbitrary '\u0000' characters โ€” and you might need some way to round-trip such strings between Java and a language like C that does use a zero byte as a terminator.
2 of 3
17
C11 states: 5.2 Environmental considerations 5.2.1 Character sets 2. In a character constant or string literal, members of the execution character set shall be represented by corresponding members of the source character set or by escape sequences consisting of the backslash \ followed by one or more characters. 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. Emphasis is mine From that we can understand that the terminating null character is always completely 0. Then, there's: 5.2.1.2 Multibyte characters A byte with all bits zero shall be interpreted as a null character independent of shift state. Such a byte shall not occur as part of any other multibyte character. 7.1.1 Definitions of terms A string is a contiguous sequence of characters terminated by and including the first null character. The term multibyte string is sometimes used instead to emphasize special processing given to multibyte characters contained in the string or to avoid confusion with a wide string. A pointer to a string is a pointer to its initial (lowest addressed) character. The length of a string is the number of bytes preceding the null character and the value of a string is the sequence of the values of the contained characters, in order.
Top answer
1 of 2
3

"NUL" is short for "NULL". Quoting ECMA-48, which lists all control characters as "8.3.xx acr - name":

8.3.88 NUL - NULL
Notation: (C0)
Representation: 00/00

NUL is used for media-fill or time-fill. NUL characters may be inserted into, or removed from, a data stream without affecting the information content of that stream, but such action may affect the information layout and/or the control of equipment.

Now, about your question:

In wikipedia it says that the ASCII NULL character is called NUL.

This is not what Wikipedia says. It says the ASCII null (lowercase!) character is called NUL. "Null character" is a term that applies to all character encodings, "NULL character" is not.

Wikipedia is correct, as there is nothing wrong with referring to this character by its official acronym.

In comment 2962254, Matteo Italia states that the NULL character is not called NULL.

He is wrong about that.

here, the table in "Character groups", the name is "NULL", abreviated "NUL"
here NUL is an abreviation, not a name

These are both correct.

in answer 30121329: ยซNUL is the name given to the first ASCII character.ยป

This is technically incorrect, but for all practical purposes correct. The acronyms are better known than the official names, and I don't see much of a problem in treating those acronyms as names.

2 of 2
1

Yes, nul, is an abbreviation of null.

Not a particularly shortened version as itโ€™s only shorter by one character, but as ASCII characters are limited to 3, so there isnโ€™t much choice really.

The uppercase standard of NUL is a convention of ASCII, for example, TAB.

๐ŸŒ
Quora
quora.com โ€บ What-is-a-null-character-NUL-on-a-system-level-and-how-can-we-use-it
What is a null character (NUL) on a system level, and how can we use it? - Quora
Answer: NUL is the ASCII character with a numeric value of zero. In C/C++ and close kin the nul character is used to mark the end of a string (rather than using the first byte or word of the โ€œstringโ€ to encode the number of characters in ...
Top answer
1 of 1
20

ASCII is only for [printable] character[s]

Not quite: in addition to printable characters, ASCII also includes a number of control characters.

ASCII code 0 (NUL) is one such control character.

To quote Wikipedia:

ASCII reserves the first 32 codes (numbers 0-31 decimal) for control characters: codes originally intended not to represent printable information, but rather to control devices (such as printers) that make use of ASCII, or to provide meta-information about data streams such as those stored on magnetic tape. For example, character 10 represents the "line feed" function (which causes a printer to advance its paper), and character 8 represents "backspace".

These days, the NUL character is most frequently used to signify the end of a character string in C. Its original purpose, however, was different:

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. 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.

Find elsewhere
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ ascii-nul-ascii-0-0-and-numeric-literal-0
ASCII NUL, ASCII 0 (โ€˜0โ€™) and Numeric literal 0?
Here we will see the ASCII NUL, ASCII 0 and the Numeric Literal 0. The ASCII null is represented as 0x00, and zero is represented as 0x30. The ASCII NUL character is used to denote the end of the string in C or C++. When programmer used โ€˜0โ€™ (character 0) it is treated as 0x30.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c++ โ€บ g-fact-72
ASCII NULL, ASCII 0 ('0') and Numeric literal 0 - GeeksforGeeks
July 23, 2025 - The ASCII (American Standard Code for Information Interchange) NULL and zero are represented as 0x00 and 0x30 respectively. An ASCII NULL character serves as a sentinel character of strings in C/C++. When the programmer uses '0' in his code, ...
๐ŸŒ
OSDev Wiki
wiki.osdev.org โ€บ Null_Character
Null Character - OSDev Wiki
From this point forward, when we mention the null character/terminator, we will refer to a 8-bit ASCII NULL character, represented as 0x00 in hexadecimal or, in C, as the escape sequence '\0' (not to confuse with "\0", which in C is a null-terminated string containing one null character).
๐ŸŒ
ASCII Table
ascii-code.com โ€บ 0
ASCII Code 0 - Null character
In the 7-bit ASCII character set, ASCII code 0 is represented by the control character โ€, also known as the null character.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 730461 โ€บ java โ€บ null-null-character
null? null character? (Beginning Java forum at Coderanch)
If some reference is set to NULL this means: "This refernce does not 'point' to anything.". In addition to that: "text" often is refered to "readable" - which limits the range from "full" ASCII 0x00 - 0x7F to only 0x20 - 0x7E as the first 32 codepoints are the basic control characters which ...
๐ŸŒ
ScienceDirect
sciencedirect.com โ€บ topics โ€บ computer-science โ€บ null-character
Null Character - an overview | ScienceDirect Topics
For example, the string โ€œHello Worldโ€ as a null-terminated string in ASCII is represented in hexadecimal as โ€œ48 65 6C 6C 6F 20 57 6F 62 6C 64 00โ€ and in decimal as โ€œ72 101 108 108 111 32 87 111 98 108 100 0โ€. 7 8 The binary representation for each character in โ€œHello Worldโ€ ...
๐ŸŒ
Mbed
os.mbed.com โ€บ questions โ€บ 60599 โ€บ How-to-get-ASCII-null
How to get ASCII null? - Question | Mbed
You get the Ascii null using: '\0'.However this is identical to just 0, 0x00, etc, since the Ascii null is, not completely accidental, equal to zero. ... Thank you, However, I do need it to be in ASCII character in the compiler since the code is expecting an ascii character posted by Majed ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ null character '\0' & null terminated strings
r/learnprogramming on Reddit: Null character '\0' & null terminated strings
November 18, 2022 -

Hello everyone!
In C, strings (character arrays) are terminated by null character '\0' - character with value zero.
In ASCII, the NUL control code has value 0 (0x00). Now, if we were working in different character set (say the machine's character set wouldn't be ASCII but different one), should the strings be terminated by NUL in that character set, or by a character whose value is zero?

For example, if the machine's character set would be UTF-16, the in C, byte would be 16bits and strings would be terminated by \0 character with value 0x00 00, which is also NUL in UTF-16.
But, what if the machine's character set would be modified UTF-8 (or UTF-7, ...). Then, according to Wikipedia, the null character is encoded as two bytes 0xC0, 0x80. How would be strings terminated in that case? By the byte with value 0 or by the null character.

I guess my question could be rephrased as: Are null terminated strings terminated by the NUL character (which in that character set might be represented by a nonzero value) or by a character whose value is zero (which in that character set might not represent the NUL character).

Thank you all very much and I'm sorry for all mistakes and errors as english is not my first language.

Thanks again.