title: Webclient encoding for DownloadString
body: <p>I'm making a program to translate CSV files using google translate. This is my code:</p>
  
  <pre><code>Dim sURL As String
      Dim oWebClient As New WebClient
      Dim sResult As String
  
      oWebClient.Encoding = System.Text.Encoding.ASCII
  
      If Not IsNothing(sTo) Then
          ' Construct URL
          sURL = String.Format("http://www.google.com/translate_t?hl=en&amp;ie=UTF8&amp;text={0}&amp;langpair={1}", sString, sFrom &amp; "|" &amp; sTo)
          sResult = oWebClient.DownloadString(sURL)
  
          sResult = sResult.Substring(sResult.IndexOf("TRANSLATED_TEXT="))
          sResult = sResult.Substring(0, sResult.IndexOf(";"))
  
          ' Get the string between the '' after Translated Text
          sResult = sResult.Substring(sResult.IndexOf("'") + 1, sResult.Count - 18)
      Else
          sResult = ""
      End If
  </code></pre>
  
  <p>Now I'm trying to translate to french, but the given result does not hold accents. For example Rejeté becomes: 'Rejet?'. The string in sResult literally holds "TRANSLATED_TEXT='Rejet?'".</p>
  
  <p>Did some googling around and at first I encoded my webclient as UTF-8 and found out ASCII should be better because ASCII actually has these characters. However ASCII also doesn't work.</p>
  
  <p>I've been trying to figure out if HttpUtility can help me, but I don't really understand how it works. <a href="https://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx" rel="nofollow noreferrer">HttpUtility</a></p>
  
  <p>Anyone with some insights?
  Thanks in advance!</p>
  
  <p>EDIT: This is a screenshot of the html visualizer of my result, the downloaddata method gives the same result as downloadstring.
  <a href="https://i.stack.imgur.com/Q7Gwj.png" rel="nofollow noreferrer">HTML Visualizer</a></p>
  
  <p>EDIT2: I almost solved it! Using Tom's link and adjusting the encoding to:</p>
  
  <pre><code>            sResult = Encoding.GetEncoding("iso-8859-1").GetString(oWebClient.DownloadData(sURL))
  </code></pre>
  
  <p>Got me closer, Rejeté now actually comes out. But for some reason
  D'accord comes out as D\x26#3.
  Anyone any idea?</p>