c# - How to decode this string to utf-8 string? -


i have code:

string url = "http://translate.google.com/m?hl=vi&sl=en&tl=vi&ie=utf-8&prev=_m&q=song"; string s = ""; webclient client = new webclient(); client.headers.add("user-agent", "mozilla/5.0 (symbianos/9.4; u; series60/5.0 nokia5800d-1/21.0.025; profile/midp-2.1 configuration/cldc-1.1 ) applewebkit/413 (khtml, gecko) safari/413"); s = client.downloadstring(url); 

when run received string format string:

danh tÆ°Ì€ buổi há»p để ca hát 

to string:

danh từ buổi họp để ca hát 

thank :)

when getting byte[] represents string, need know encoding used before getting it.

in case, utf-8, setting encoding of webclient results in correct string:

string url = "http://translate.google.com/m?hl=vi&sl=en&tl=vi&ie=utf-8&prev=_m&q=song"; string s = ""; webclient client = new webclient(); client.encoding = encoding.utf8; client.headers.add("user-agent", "mozilla/5.0 (symbianos/9.4; u; series60/5.0 nokia5800d-1/21.0.025; profile/midp-2.1 configuration/cldc-1.1 ) applewebkit/413 (khtml, gecko) safari/413"); s = client.downloadstring(url); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -