Using Character Encoding in ASP.NET

Open the file named web.config in the ASP.NET project. The value of requestEncoding attribute in globalization element is “utf-8”. It means the requested texts were encoded as UTF-8 character set. Because SCO5.05 does not support UTF-8, therefore the requested texts where changed.

VB:

Public Shared Function unicode_iso8859(ByVal src As String) As String
Dim iso As Encoding = Encoding.GetEncoding(“iso8859-1”)
Dim unicode As Encoding = Encoding.UTF8
Dim unicodeBytes As Byte() = unicode.GetBytes(src)
Return iso.GetString(unicodeBytes)
End Function

Public Shared Function iso8859_unicode(ByVal src As String) As String
Dim iso As Encoding = Encoding.GetEncoding(“iso8859-1”)
Dim unicode As Encoding = Encoding.UTF8
Dim isoBytes As Byte() = iso.GetBytes(src)
Return unicode.GetString(isoBytes)
End Function

label1.Text = iso8859_unicode(MyString)

more details in http://www.codeproject.com/KB/aspnet/Encoding_in_ASPNET.aspx

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *