By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

memory stream, xmltextwriter issue

P: n/a
hi all

i have the following class:

<Serializable()> _
Public Class MVR_Inputs
Public FirstName As String
Public MiddleName As String
Public LastName As String
Public Suffix As String
Public Dob As String
Public Ssn As String
Public Gender As String
Public DriversLicenseNumber As String
Public DriversLicenseState As String
Public YouthCheck As String
Public CustomerBatchID As String
Public CustomerOrderID As String
Public TestMode As Boolean = False
Public TimePeriod As Integer
Public RequestType As String
End Class

which i attempt to serialize by using this code:

Dim objMemStrm As MemoryStream
Dim objXmlWriter As XmlTextWriter
Dim objXmlSerializer As XmlSerializer
Dim byteArray() As Byte

objMemStrm = New MemoryStream
objXmlWriter = New XmlTextWriter(objMemStrm, Encoding.UTF8)
objXmlSerializer = New XmlSerializer(oSubject.GetType())
objXmlSerializer.Serialize(objXmlWriter, oSubject)
byteArray = objMemStrm.GetBuffer
sSerializedReq = System.Text.Encoding.UTF8.GetString(byteArray)

the serialization works fine, except that the first character of of
sSerializedReq is always ASCII character 239 - an i with 2 small dots
on top

any ideas ?

thanks in advance

Mar 30 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a

The characters are the Byte Order Mark (BOM)

which are emitted when using the default UTF8 encoding

To prevent them being emitted use an instance of the UTF8 Encoding that
does not emit them

objXmlWriter = New XmlTextWriter(objMemStrm, New

Mar 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.