XmlTextWriter Embedding NULLs in Files

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
 
A

Alex Feinman [MVP]

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');
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top