It's all about character sets. The utf8_decode function decodes to iso 8859-1, which apparently doesn't support Japanese, Chinese, etc. I did not know that before now, but I did a quick Google search and found a number of possible solutions.
Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On May 27, 2009, at 8:16 PM, alicia130 wrote: > > For Japanese, if I don't use the utf8_decode, I get ???? if I do use > it I get - ��������ゃ���� > > Have you seen this before? > > On May 21, 11:09 am, Jeremy Geerdes <[email protected]> wrote: >> I think you need to use the PHP's utf8_decode function on your >> response string. The Language API deals in the utf-8 character set; >> PHP generally handles ISO-8859-1 character set. >> >> Jeremy R. Geerdes >> Effective website design & development >> Des Moines, IA >> >> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp >> ://jgeerdes.blogspot.comhttp://jgeerdes.wordpress.com >> [email protected] >> >> Unless otherwise noted, any price quotes contained within this >> communication are given in US dollars. >> >> If you're in the Des Moines, IA, area, check out Debra Heights >> Wesleyan Church! >> >> And check out my blog, Adventures in Web Development, >> athttp://jgeerdes.blogspot.com >> ! >> >> On May 21, 2009, at 10:58 AM, alicia130 wrote: >> >> >> >>> 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 theSpanishspecial 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 -~----------~----~----~----~------~----~------~--~---
