Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a binary null character?

Tags:

c#

I have a requirement to create a sysDesk log file. In this requirement I am supposed to create an XML file, that in certain places between the elements contains a binary null character.

Can someone please explain to me, firstly what is a binary null character, and how can I write one to a text file?

like image 588
JL. Avatar asked Sep 28 '09 16:09

JL.


People also ask

WHAT IS null character with example?

In databases and spreadsheets, a null character can also be used as padding. An example of a null character is when a software developer declares a variable without specifying a value, or sets it equal to nothing.

How do you type a null character?

Method 1: The ∅ symbol can be entered by going into "Symbols", choose "Mathematical Characters" and from the dropdown "Subset". Method 2: Type 2205 and then press "Alt + X".

What is the null character in ASCII?

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. This is a hexadecimal number.

How many bits is a null character?

NULL will use 1 bit in the NULL bitmap.


2 Answers

I suspect it means Unicode U+0000. However, that's not a valid character in an XML file... you should see if you can get a very clear specification of the file format to work out what's actually required. Sample files would also be useful :)

Comments are failing me at the moment, so to address a couple of other answers:

  • It's not a string termination character in C#, as C# doesn't use null-terminated strings. In fact, all .NET strings are null-terminated for the sake of interop, but more importantly the length is stored independently. In particular, a C# string can entirely validly include a null character without terminating it:

    string embeddedNull = "a\0b";
    Console.WriteLine(embeddedNull.Length); // Prints 3
    
  • The method given by rwmnau for getting a null character or string is very inefficient for something simple. Better would be:

    string justNullString = "\0";
    char justNullChar = '\0';
    
like image 139
Jon Skeet Avatar answered Sep 23 '22 06:09

Jon Skeet


A binary null character is just a char with an integer/ASCII value of 0.

You can create a null character with Convert.ToChar(0) or the more common, more well-recognized '\0'.

like image 20
Mark Rushakoff Avatar answered Sep 19 '22 06:09

Mark Rushakoff