I am attaching the code below.
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
public class Translator {
public static void main(String[] args) {
// Translate trans = new Translate();
try{
System.setProperty("http.proxyHost", "192.16.3.254");
System.setProperty("http.proxyPort", "8080");
Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java/");
String translatedText = Translate.execute("How are you?", Language.ENGLISH, Language.H开发者_开发技巧INDI);
System.out.println("translated text :" + translatedText);
}catch (Exception e) {
e.printStackTrace();
}
}
}
This is giving output as translated text : ?? ???? ????
but for Language.FRENCH,Language.SPANISH its giving the translated text.
Could you please tell a solution for this.
If console can not display the chars correctly, it may caused by the Local Setting of the host operation system. If the system local is set to be English, then multi-bytes characters may not be displayed correctly. You can try to write it to a file and check it using a text editor, like Notepad++. And make sure you choose the correct encoding in Notepad++ :)
精彩评论