vikassharma27 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Displaying ??? when i tried to translate English to chinese/japanese.. #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
public class TestJava {
    public static void main(String[] args) throws Exception {
        GoogleAPI.setHttpReferrer("en-US");
        Language toLanguage = Language.fromString("ja");
        String t = Translate.execute("Hello World", 
Language.ENGLISH, toLanguage);
        System.out.println(t);
}
}

When i try to run this(English to chinese/japanese..), its displaying ??? 
instead of localized string, where as when i tried to convert english to 
spanish,portugese its working fine.

OS -Windows
Eclipse, Tomcat

any suggestions?

Thanks in advance

Original issue reported on code.google.com by bonuanil...@gmail.com on 28 Apr 2010 at 6:14

GoogleCodeExporter commented 8 years ago
I think it's perhaps a UTF-8 issue with Windows, not this API, I'm sure you can 
set 
the character encoding somewhere - others have had the same issue. 
Unfortunately (in 
this instance if no other) I'm not a Windows user so I'm not sure where you set 
that.

Original comment by rich.mid...@gmail.com on 28 Apr 2010 at 7:05

GoogleCodeExporter commented 8 years ago
ya i tried converting the output string to UTF-8 format, but its displaying 
some 
different characters other than ???.

below is the code sample i tried

public class TranslateExample {
    public static void main(String[] args) throws Exception {
        GoogleAPI.setHttpReferrer("en-US");
        Language toLanguage = Language.fromString("ja");
        String t = Translate.execute("Hello World", 
Language.ENGLISH, toLanguage);
        System.out.println(new String(t.getBytes("UTF-8")));
}
}

how to get the exact translated string ?

any suggestions ?

Original comment by bonuanil...@gmail.com on 28 Apr 2010 at 10:16