I'm a web services developer and there are some bugs about encoding. Point is that my web service is using people from countries with different encodings (russian - windows-1251, baltic - windows-1257, ect).
At first i encoding problem solved easely because data from database returned into dataset type. I used code like this (simpled):
Expand|Select|Wrap|Line Numbers
- ...
- Dim Com As New SqlCommand
- Dim name As String
- Dim reader As SqlDataReader = oCmd.ExecuteReader(CommandBehavior.SequentialAccess)
- Do While reader.Read()
- Dim spaceByteArray(0) As Byte
- 'detect region language
- If _region.Contains("RU") Then 'if russian
- 'read 'name'column data
- retval = reader.GetBytes(5, 0, outbyte, 0, 255)
- name = Encoding.GetEncoding("windows-1251").GetString(outbyte).Trim()
- End If
- Loop
- ...
But now i must encoding data what are returned from "FOR XML EXPLICIT" structure - XML document.
Question is - is it possible read (ExecuteXmlReader) concrete XML nodes and their values into byte array when reading from database how it do "ExecuteReader"?
Or there is other way to encode when reading, because when data is returned and writed into XMLDocument variable it is impossible to recognize and change it.
Thanks!