XmlTextWriter Embedding NULLs in Files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Platform: Symbol MC9000 (Gemini Short)
OS: PPC2003
..NET CF
Sybase ASA Client Version 8 on the Device

Although the evidence of 32 NULLs (0x00) was discovered in the final XML
file, is it possible for StringBuilder, String, or StreamWriter (used as part
of the XmlTextWriter routines) to somehow shift pointers 32 bytes and produce
32 0x00s. I validated that I can perform an Encoding.ASCII.GetString from a
byte array (byte [] temp = new byte[32]) and get 32 nulls.

Mark
 
Keep in mind that if you have a StringBuilder that has say the following
contents:
0x42, 0x6F, 0x62, 0, 0, 0
and the Capacity=10 and Length = 6, the ToString() method will produce
"Bob\0\0\0";

If you want to get rid of trailing spaces, use
Stringbuilder.ToString().Trim('\0');
 
Thanks Alex. The nulls, however, showed up in the middle of an element tag.
Should have been: <c> for the start of column. Instead it ended up "<"
followed by 32 nulls, follwed by "c>." Wierd.

As a safety measure, I will implement your recommendation to trim trailing
null, just in case.
 
Back
Top