H.Al H.Al - 4 months ago 8x
Vb.net Question

Google Translate in VB .Net returning ??? for Arabic Language

I am working on a small function that translates string to different languages. Actually it's working fine for all languages except Arabic, it's returning question marks ????. Any hint? You can view the code below

Thanks in advance

Dim translateThis = "hello"
Dim languagePair = "en|ar"
Dim url3 = String.Format("http://www.google.com/translate_t?hl=en&text={0}&langpair={1}", translateThis, languagePair)
Dim result as string

Dim client As WebClient = New WebClient()
client.Encoding = System.Text.UTF8Encoding.UTF8

result = client.DownloadString(url3)
result = result.Substring(result.IndexOf("id=result_box") + 151, 500)
result = result.Substring(0, result.IndexOf("</span>"))


Try to use for Arabic Windows Encoding(1256) :

client.Encoding = Encoding.GetEncoding(1256)