I am calling google translate with the below code (I used Curl to
allow me to translate more than 500 characters).  However, I am having
issues with the Spanish special characters not being returned
correctly.

Here is an example of what is being returned:
í³      instead of ó
ó    instead of ó
í¡      instead of á
í±     instead of ñ
etc.

Currently, I have to do a string replace in PHP to clean up the
garbage.  I'd rather not hard code this though.  Has anyone ran into
this issue before?

function translate($transText,$tlang){

          define('POSTURL', 'http://ajax.googleapis.com/ajax/services/
language/translate');
          // INITIALIZE ALL VARS
          $ch='';
          $Rec_Data='';

          $ch = curl_init(POSTURL);
          curl_setopt($ch, CURLOPT_POST          ,1);
          curl_setopt($ch, CURLOPT_POSTFIELDS        ,
          'q='. urlencode($transText). '&v=1.0'. '&langpair=%7C' . $tlang);

          curl_setopt($ch, CURLOPT_FOLLOWLOCATION    ,1);
          curl_setopt($ch, CURLOPT_HEADER            ,0);    // DO NOT RETURN
HTTP HEADERS
          curl_setopt($ch, CURLOPT_RETURNTRANSFER    ,1);    // RETURN THE
CONTENTS OF THE CALL

      $rec_Data = json_decode(curl_exec($ch), true);
      return $rec_Data['responseData']['translatedText'];
        }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to