LoadBytes() followed by GetBytes() results in incorrect output


There is a minor problem with the GetBytes() implementation which causes unexpected binary output.
If the first code page used in the XML document is the same as the last code page used in an earlier LoadBytes() call, tagCodeSpace.CodePageId will still be set to that code page. This in turn prevents a SWITCH_PAGE token from being outputted.
In my opinion the current code page should be set to 0 at the beginning of WBXMLDocument.GetBytes(). This will cause the SWITCH_PAGE token to be written.
For example, consider:
CodePage 1:
MyXml = 05
byte[] buffer = myDoc.GetBytes();
Expected output:
... 03 01 45 53 6F 6D ...
Actual output:
... 45 53 6F 6D ...
Closed May 11, 2009 at 6:40 PM by jcdekoning


jcdekoning wrote May 11, 2009 at 6:40 PM

Updated source of WBXMLDocument.cs which sets the active codepages for the tag and attribute code space to 0 at the beginning of the encoder method GetBytes().

Thanks for reporting this issue.

wrote May 11, 2009 at 6:40 PM

wrote Feb 13, 2013 at 11:43 PM

wrote May 16, 2013 at 2:24 AM