I spent hours trying to figure out what to do to be able to make my unicode string (which contained english characters) to show up in my web browser. It always showed up as Question Marks (?????) or just plain garbled text (like Chinese characters). I tried using different responseencoding and fileencoding values in web.config, but to no avail.
For some reason Microsoft has change StrConv function and has removed the vbUniCode and vbFromUnicode constants. So, you can no longer use that to get an ASCII representation of the string. Well, this is what finally worked for me (assume the string to be converted is in the variable strBody):
Imports System.Text
‘This will take care of unicode messages. Basically it strips everything down to ASCII
strBody = Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(strBody))
Before :
After :
Filed under: .net 1.1, ASP.NET 1.1, ASP.net 2.0, VB.Net
Definitely useful. I’ll bookmark this and try to remember where I saw it … I know I’ll need to know this at some point in the near future. (esp since I’ll be taking asp.net this semester)
Thanks
This code helps me too…
thanks for your great work.
is it a bug?
1) Dim str As String = “123456789″
2) str = Encoding.Unicode.GetString(Encoding.ASCII.GetBytes(str))
3)str = Encoding.ASCII.GetString(Encoding.Unicode.GetBytes(str))
result is :
12345678 !!!!
where is 9?
Please Help me!!
Hello Sir,
I want to display the Unicode text to Hindi.
I had a text which contains the Unicode data i want to display that data to hindi format.
Ex. Unicode data=0928;0940;0932;092E
Hindi Data =निलम
Please tell me how to convert Unicode data to Hindi using vb.net.
Thanks in Advance,
Atul Bari.