469,628 Members | 1,028 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

memory stream, xmltextwriter issue

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
1 2733

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.

Similar topics

5 posts views Thread by Qin Zhou | last post: by
13 posts views Thread by Matthew Wieder | last post: by
reply views Thread by Marc Schumacher via DotNetMonster.com | last post: by
2 posts views Thread by phoenix | last post: by
4 posts views Thread by Fabiano | last post: by
3 posts views Thread by lisa.bogart | last post: by
9 posts views Thread by Bharathi Harshavardhan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.