VB.NET System.Text.Encoding Conversion Example

Wednesday, July 29, 2015 Unknown 1 Comments

VB.NET System.Text.Encoding Conversion Example

I ran into an issue on one of the ASP.net applications where the encoding was being passed in as UTF-8 but need to be Window2-1252 or ISO-8859-1 to handle the French encoding.
The Default encoding was ISO

Dim resbytes() As Byte = System.Text.Encoding.UTF8.GetBytes(Response.ToCharArray)
Response = System.Text.Encoding.Default.GetString(System.Text.Encoding.Convert(System.Text.Encoding.Default, System.Text.Encoding.UTF8, resbytes))

Here the Default is in the source and it would convert to UTF8


Dim resbytes() As Byte = System.Text.Encoding.UTF8.GetBytes(Response.ToCharArray)
Response = System.Text.Encoding.Default.GetString(System.Text.Encoding.Convert(System.Text.Encoding.Default, System.Text.Encoding.UTF8, resbytes))

Above the bold highlights the String to Byte convertion and then being passed back to a string.

1 comment :

  1. Hey,

    When ever I surf on web I come to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Plenty of useful information on adventuresofwork.blogspot.com. I am sure due to busy scedules we really do not get time to care about our health. Are you really serious about your weight?. Recent Scientific Research displays that closely 80% of all USA grownups are either fat or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Therefore if you're one of these individuals, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is not like piece of cake. If you improve some of your daily diet habbits then, its like piece of cake to quickly lose weight.

    About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for fast weight loss.

    ReplyDelete

Powered by Blogger.