Null character

The null character (also null terminator) is a control character with the value zero.[1][2][3][4] It is present in many character sets, including those defined by the Baudot and ITA2 codes, ISO/IEC 646 (or ASCII), the C0 control code, the Universal Coded Character Set (or Unicode), and EBCDIC. It is available in nearly all mainstream programming languages.[5] It is often abbreviated as NUL (or NULL, though in some contexts that term is used for the null pointer). In 8-bit codes, it is known as a null byte.

The original meaning of this character was like NOP—when sent to a printer or a terminal, it has no effect (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 the programming language C and its derivatives and in many data formats, where it serves as a reserved character used to signify the end of a string,[6] often called a null-terminated string.[7] 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 in the null-terminated string article).

Representation

In source code, the null character is often represented as the escape sequence \0 in string literals (for example, "abc\0def") or in character constants ('\0'); the latter may also be written instead simply as 0 (without quotes nor slash).[8] 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 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.[9] Other escape sequences that are found in use in various languages are \000, \x00, \z, or \u0000. A null character can be placed in a URL with the percent code %00.

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 known as null byte injection and can lead to security exploits.[10]

In caret notation the null character is ^@. On some keyboards, one can enter a null character by holding down Ctrl and pressing @ (on US layouts just Ctrl+2 will often work, there being no need for ⇧ Shift to get the @ sign).

The Hexadecimal notation for null is 00. Decoding the Base64 string AA== also yields the null character.

In documentation, the null character is sometimes represented as a single-em-width symbol containing the letters "NUL". In Unicode, there is a character for this: U+2400 SYMBOL FOR NULL.

Encoding

In all modern character sets, the null character has a code point value of zero. In most encodings, this is translated to a single code unit with a zero value. For instance, in UTF-8 it is a single zero byte. However, in Modified UTF-8 the null character is encoded as two bytes: 0xC0,0x80. This allows the byte with the value of zero, which is now not used for any character, to be used as a string terminator.

References

  1. ^ ASCII format for Network Interchange. IETF. sec. 5.2. doi:10.17487/RFC0020. 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. Archived from the original (PDF) on 2014-05-12. Position: 0/0, Name: Null, Abbreviation: Nul
  3. ^ "Unicode Character 'NULL' (U+0000)". Retrieved 2018-10-20.
  4. ^ "C0 Controls and Basic Latin" (PDF). Unicode Consortium. 2018. Retrieved 2018-10-20.
  5. ^ "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
  6. ^ "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
  7. ^ Working Draft, Standard for Programming Language C++ (PDF) (ISO 14882 standard working draft), ISO/IEC, 28 February 2011, p. 427, N3242=11-0012, retrieved 27 February 2013, 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); no other element in the sequence has the value zero.
  8. ^ 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."}}
  9. ^ In YAML this combination is a separate escape sequence.
  10. ^ Null Byte Injection WASC Threat Classification Null Byte Attack section.

Read other articles:

Military insignia United States Space Force rank insignia are used to indicate the rank and status of the United States Space Force officers and enlisted personnel. Equivalency between the military services is indicated by associated NATO code and pay grade.[1] Insignia Officer insignia US DoDpay grade O-10 O-9 O-8 O-7 O-6 O-5 O-4 O-3 O-2 O-1 Officer candidate NATO code OF-9 OF-8 OF-7 OF-6 OF-5 OF-4 OF-3 OF-2 OF-1 OF(D) Insignia Various insignia Service dress uniform (Class A) Se...

Hard, high-strength copper alloy CuBe redirects here. For other, see cube (disambiguation). Adjustable Wrench with 'BeCu' on the side, to show that it is made from beryllium copper Beryllium copper (BeCu), also known as copper beryllium (CuBe), beryllium bronze, and spring copper, is a copper alloy with 0.5–3% beryllium.[1] Copper beryllium alloys are often used because of their high strength and good conductivity of both heat and electricity.[2] It is used for its ductility...

Natal CommandPart of Union Defence Force South African Defence Force South African National Defence Force Natal Command[1] (3 September 1939 – July 1940)Parent unitUnion Defence ForceComponentsHQ Durban, Natal A. Permanent Force[1] Royal Durban Light Infantry Company, The Special Service Battalion: Durban 3rd Heavy Battery, South African Permanent Garrison Artillery: Durban Beach 4th Heavy Battery, South African Permanent Garrison Artillery: The Bluff, Durban B....

Ця стаття не містить посилань на джерела. Ви можете допомогти поліпшити цю статтю, додавши посилання на надійні (авторитетні) джерела. Матеріал без джерел може бути піддано сумніву та вилучено. (липень 2019) Романтичне кохання — одна із культурно-історичних форм любов...

لواء قصبة جرش الموقع الجغرافي تقسيم إداري البلد  الأردن[1] العاصمة جرش التقسيم الأعلى جرش  خصائص جغرافية إحداثيات 32°15′07″N 35°52′14″E / 32.25189°N 35.8705°E / 32.25189; 35.8705  الأرض 402 كم² كم² الارتفاع 120- إلى 1247 متر السكان التعداد السكاني 244,000 نسمة (إحصاء 2016) الكثافة ا...

2007 European Athletics U23 ChampionshipsTrack events100 mmenwomen200 mmenwomen400 mmenwomen800 mmenwomen1500 mmenwomen5000 mmenwomen10,000 mmenwomen100 m hurdleswomen110 m hurdlesmen400 m hurdlesmenwomen3000 msteeplechasemenwomen4 × 100 m relaymenwomen4 × 400 m relaymenwomenRoad events20 km walkmenwomenField eventsHigh jumpmenwomenPole vaultmenwomenLong jumpmenwomenTriple jumpmenwomenShot putmenwomenDiscus throwmenwomenHammer throwmenwomenJavelin throwmenwomenCombined eventsHeptathlonwomen...

Lambang Rheinkreis Rheinkreis (bahasa Inggris: Circle of the Rhine,[1] secara harfiah berarti lingkaran Rhein) adalah nama yang mengacu kepada wilayah di sebelah barat Sungai Rhein dari tahun 1816 hingga 1837 yang menjadi salah satu dari 15 (dan kemudian 8) distrik administratif Kerajaan Bayern. Sebelum meletusnya Perang Koalisi Pertama (1792), sebagian besar wilayah Rheinkreis merupakan bagian dari Elektorat Pfalz. Pada saat berlangsungnya Kongres Wina pada tahun 1815, wilayah in...

Office suite by Microsoft released in 2000 Microsoft Office 2000Microsoft Office 2000 core programs running on Windows NT 4.0, with the Office Assistant presentDeveloper(s)MicrosoftInitial releaseJune 7, 1999; 24 years ago (1999-06-07)[1]Final releaseService Pack 3 (9.0.6926)[2] / October 21, 2002; 21 years ago (2002-10-21)[3] Operating system Windows 95 Windows NT 4.0 SP3 or later Windows 98 Windows 2000 Windows Me Windows XP Window...

Type of cosmetics White petrolatum A moisturizer, or emollient,[1] is a cosmetic preparation used for protecting, moisturizing, and lubricating the skin. These functions are normally performed by sebum produced by healthy skin.[2] The word emollient is derived from the Latin verb mollire, to soften.[3] Mechanism of action In the human body, water constantly evaporates from the deeper layers of the skin through an effect known as transepidermal water loss. By regulating...

International airport in Villahermosa, Tabasco, Mexico Villahermosa International AirportAeropuerto Internacional de VillahermosaIATA: VSAICAO: MMVASummaryAirport typePublicOwner/OperatorGrupo Aeroportuario del SuresteServesVillahermosa, Tabasco, MexicoOpened1979Time zoneCST (UTC-06:00)Elevation AMSL14 m / 46 ftCoordinates17°59′42″N 92°49′02″W / 17.99500°N 92.81722°W / 17.99500; -92.81722Websitewww.asur.com.mx/Contenido/Villahermosa/shoppingM...

City neighborhood in Madrid, Community of Madrid, SpainLas DeliciasCity neighborhoodCountrySpainAut. communityCommunity of MadridMunicipalityMadridDistrictArganzuela Las Delicias is a and administrative neighborhood (barrio) of Madrid belonging to the district of Arganzuela.[1] References ^ Díaz Pérez, Gabriela (24 February 2012). Brooklyn está en Madrid. El País (in Spanish). Prisa. Retrieved 21 August 2019. vteDistricts and wards of MadridArganzuela Atocha Imperial La Chopera La...

Ця стаття не містить посилань на джерела. Ви можете допомогти поліпшити цю статтю, додавши посилання на надійні (авторитетні) джерела. Матеріал без джерел може бути піддано сумніву та вилучено. (березень 2018) Соборні послання (англ. catholic epistles) — це послання з Нового Зап...

2000 Indian filmPottu AmmanDVD cover of the Tamil versionDirected byK. Rajarathnam (Tamil)R. K. Selvamani (Telugu)Written byR. B. RathanR. SelvarajProduced byS. MathiRamprasad ReddyStarringVenuRojaSuvaluxmiCinematographyK. RajarathnamEdited byAnil MalnadMusic byS. D. ShanthakumarProductioncompaniesMangala ProductionsSuper Hit FilmsRelease date8 December 2000CountryIndiaLanguagesTamilTelugu Pottu Amman is a 2000 Indian Tamil-language devotional film directed by K. Rajarathinam and produced by ...

梅克倫堡-什未林大公國Großherzogtum Mecklenburg-Schwerin1815年—1918年 国旗 国徽 梅克倫堡-什未林在德意志帝國中的位置地位  德意志邦聯 邦國 北德意志邦联邦國  德意志帝國 邦國 首都什未林政府君主制大公 • 1815年–1837年 腓特烈·法蘭茲一世• 1837年–1842年 保羅·腓特烈• 1842年–1883年 腓特烈·法蘭茲二世• 1883年–1897年 腓特烈·法蘭茲三世• 189...

American actor Actor James Riordan James Riordan (born February 15, 1969 in Cleveland, Ohio) is a New York City-based Broadway, film and television actor. Theatre work Broadway On Broadway James Riordan played Frank Whitworth in Jerusalem with Mark Rylance, and in The Elephant Man with Billy Crudup, Kate Burton and Rupert Graves. The New York Daily News review of The Elephant Man called his performance wonderful in a variety of roles[1] and Curtain UP said, The supporting cast is also...

American politician Deanna BallardMember of the North Carolina Senatefrom the 45th districtIn officeApril 27, 2016 – January 1, 2023Preceded byDan SoucekSucceeded byRalph Hise (Redistricting) Personal detailsBorn (1978-10-02) October 2, 1978 (age 45)Blowing Rock, North CarolinaPolitical partyRepublicanAlma materBelmont University (BBA) Deanna Ballard (born October 2, 1978) is an American politician who served in the North Carolina Senate from the 45th district from 2016 to 202...

This article relies excessively on references to primary sources. Please improve this article by adding secondary or tertiary sources. Find sources: Potters Bar Clinic – news · newspapers · books · scholar · JSTOR (May 2021) (Learn how and when to remove this template message) The Potters Bar Clinic is a mental health hospital in Hertfordshire, UK which has 23 acute beds. It is currently owned and run by Elysium Healthcare. The hospital has two wards, ...

American naturalist and author (1870–1922) Enos Millscirca 1915BornEnos Abijah Mills(1870-04-22)April 22, 1870Linn County, KansasDiedSeptember 21, 1922(1922-09-21) (aged 52)ColoradoOccupation(s)Naturalist, homesteader, and authorKnown forLeading the establishment of the Rocky Mountain National Park Enos Abijah Mills (April 22, 1870 – September 21, 1922) was an American naturalist, author and homesteader. He was the main figure behind the creation of Rocky Mountain National Park....

American politician (1884–1967) For those of a similar name, see Alexander Wylie (disambiguation). Senator Wiley redirects here. For other uses, see Senator Wiley (disambiguation). Alexander WileyWiley in April 1939United States Senatorfrom WisconsinIn officeJanuary 3, 1939 – January 3, 1963Preceded byF. Ryan DuffySucceeded byGaylord Nelson Personal detailsBorn(1884-05-26)May 26, 1884Chippewa Falls, Wisconsin, U.S.DiedOctober 26, 1967(1967-10-26) (aged 83)Germantown, Pennsyl...

Questa voce o sezione sull'argomento automobili non cita le fonti necessarie o quelle presenti sono insufficienti. Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Segui i suggerimenti del progetto di riferimento. Questa voce o sezione sull'argomento automobili non è ancora formattata secondo gli standard. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Segui i suggerimenti del progetto di riferiment...