Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: UCS-2 to UTF-8 character conversion in VB


Message #1 by "Peter Drivas" <peter.drivas@g...> on Thu, 29 Nov 2001 16:08:51
Hi,

I have an application that retieves XML from MS SQL using the FOR XML 
AUTO, ELEMENTS directive. I read the data into a stream whose type 
attribute is set to "adTypeText" and whose charset attribute is set 
to "UTF-8". When I attempt to transform this XML using XSLT, I get an 
invalid character error. My understanding of the problem so far is that MS 
SQL stores data in UCS-2 format, while XML uses UTF-8. I have attempted to 
use the techniques suggested in the MSDN article, "Q232580: Storing UTF-8 
Data in SQL Server", but haven't been able to get the Windows function 
WideCharToMultiByte to work as I would expect. It appears the stream 
settings aren't working as I expect either.

Anybody have any experience doing these character conversions in VB? For 
now, I work around the problem by scanning for the offending character and 
replacing it with an ASCII "equivalent". This isn't a great solution since 
I may miss some characters. Any information or help you can send would be 
greatly appreciated.

Thanks,
Peter

  Return to Index