title: Google TTS API: Encoding GET request with PHP
body: <p>--- SOLVED ---</p>
  
  <p>Problem solved. Solution is simple:</p>
  
  <pre><code>file_get_contents("http://translate.google.com/translate_tts?tl=de&amp;q=".urlencode($str)."&amp;ie=UTF-8")
  </code></pre>
  
  <p>To those coming here from search engine: Make sure you set the file charset to UTF-8,  include the ie=UTF-8 parameter into the URL, urlencode your string. Everything should be fine then.</p>
  
  <p>ORIGINAL POST WAS:</p>
  
  <p>I have a problem with making PHP send a correctly encoded GET request to the Google TTS API.</p>
  
  <pre><code>$str='This is a German string which contains crazy Umlaute like ä (like in Häuser) or ü (like in Übermensch). Sehr deutsch halt.';
  file_get_contents("http://translate.google.com/translate_tts?tl=de&amp;q=".$str."&amp;ie=UTF-8");
  </code></pre>
  
  <p>All included PHP files are encoded in UTF-8 (no byte order marks). What Google TTS returns to me is an MP3 file which spells the "Umlaute" not like Übermensch, but like A~1/4bermensch. This problem has nothing to do with the client side.</p>
  
  <p>I think Google is expecting an ASCII string, this might be my problem? When I type the GET line into my browser manually however, it spells everything correctly. See also:</p>
  
  <p><a href="https://stackoverflow.com/questions/10255130/google-tts-api-for-arabic-chinese-and-greek">stackoverflow - Google TTS API for Arabic, Chinese and Greek</a></p>
  
  <p>Thanks for help!!</p>