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?
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:
The method given by rwmnau for getting a null character or string is very inefficient for something simple. Better would be: