I have recently been given the task of writing a piece of FoxPro to interface with Google Translate so we can translate text in our software to the language of the current user/machine.
The code I have found/modified/written works perfectly for Latin-based character sets, but if you try something like Chinese it comes back all question marks.
I have already tried using the VFP function STRCONV() with every option combination possible, but no success. I also tried setting the LocaleID before the text is manipulated in any way--still no luck.
At this point, I am out of ideas. Being an old DOS programmer, I have little to no experience in dealing with unicode.
I have not included any code, because as I said, the code works fine unless you try to use it with Chinese (or Japanese).
Please help!
Edit: This is the function which does the communication with google. There are other support functions, but they dont have to do with the encoding.
* MODIFIED BY: MICHAEL COOLEY - 11/19/2012
* PURPOSE: TRANSLATE TEXT FROM ONE LANGUAGE TO ANOTHER
* EXPECTS: STRING (SOURCE LANGUAGE CODE)
* STRING (DESTINATION LANGUAGE CODE)
* STRING (THE TEXT TO TRANSLATE)
* RETURNS:
FUNCTION Translate(lcFrom,lcTo,lcText)
LOCAL lcHttp AS MSXML2.XMLHTTP
LOCAL lcRequest AS String
lcRequest = "http://translate.google.com/translate_a/t?client=j" + ;
"&"+"text="+this.EncodeURL(lcText)+"&"+"hl="+lcTo+"&"+"sl="+lcFrom+"&"+"tl="+lcTo
lcHttp = CREATEOBJECT("MSXML2.XMLHTTP")
lcHttp.open("GET",lcRequest,.f.)
IF lcHttp.status == 200
lcText = this.GetTranslationString("trans", lcHttp.responseText) + CHR(10)
ELSE
lcText = ""
ENDIF
RETURN lcText
ENDFUNC