akrishna77 / java-google-translate-text-to-speech

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

Question marks while translating from Japanese to English #6

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use a Japanese Unicode String as the input string
2. Translate from Japanese to English

What is the expected output? What do you see instead?
I should ideally see the English translation of the Japanese String; however, 
it returns a bunch of question marks. For example, it translates 
夏だから今日は as ? ? ? ? ? and so on.

What version of the product are you using? On what operating system?
Android 4.4.4. Works fine for the same string on Linux.

Please provide any additional information below.

Original issue reported on code.google.com by taninam...@gmail.com on 29 Jun 2014 at 6:41

GoogleCodeExporter commented 8 years ago
is there a solution for this yet? thanks!

Original comment by javierco...@gmail.com on 14 Oct 2014 at 2:01

GoogleCodeExporter commented 8 years ago
I would also like to know how to solve this please.

Original comment by pb...@york.ac.uk on 16 Feb 2015 at 6:39

GoogleCodeExporter commented 8 years ago
I found a solution to this by encoding the request as follows:

<code>
...
final HttpClient client = new HttpClient();
final PostMethod method = new PostMethod("...service url...");
method.addRequestHeader("X-HTTP-Method-Override", "GET");
final Part[] parts = {
  new StringPart("key", "...my key...", "UTF-8"),
  new StringPart("source", "ja", "UTF-8"),
  new StringPart("target", "en", "UTF-8"),
  new StringPart("q", "...japanese content...", "UTF-8")
};
method.setRequestEntity(new MultipartRequestEntity(parts, method.getParams()));
InputStream responseIS = method.getResponseBodyAsStream();
...
</code>

Hope this helps!

Javier C.

Original comment by javierco...@gmail.com on 16 Feb 2015 at 9:07