littlebigman
Well-known member
- Joined
- Jan 5, 2010
- Messages
- 75
- Programming Experience
- Beginner
Hello
I'm using the following asynchronous code to download a web page and use a regex (not shown) to extract bits of infos:
Problem is, the web page is in UTF-8 while RichTextBox and MessageBox display data in ANSI (accented characters are displayed as funny characters). Is there an easy way to convert data returned in e.Result from UTF-8 to ANSI?
Thank you.
I'm using the following asynchronous code to download a web page and use a regex (not shown) to extract bits of infos:
VB.NET:
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub AlertStringDownloaded(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
If e.Cancelled = False AndAlso e.Error Is Nothing Then
Dim Content As String
RichTextBox1.Text = CStr(e.Result)
RichTextBox1.Refresh()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Coded in UTF-8
Dim URL As String = "http://www.acme.com"
Dim webClient As New WebClient
AddHandler webClient.DownloadStringCompleted, AddressOf AlertStringDownloaded
RichTextBox1.Clear()
'Synchronous DownloadString freezes UI while waiting for web page
webClient.DownloadStringAsync(New Uri(URL))
'Go to AlertStringDownloaded
End Sub
End Class
Problem is, the web page is in UTF-8 while RichTextBox and MessageBox display data in ANSI (accented characters are displayed as funny characters). Is there an easy way to convert data returned in e.Result from UTF-8 to ANSI?
Thank you.
Last edited: