diff options
author | wjoe <joe@lc8n.com> | 2013-09-20 14:28:42 +0100 |
---|---|---|
committer | wjoe <joe@lc8n.com> | 2013-09-20 14:28:42 +0100 |
commit | 47352782cc298e3f63c67f87ab77b882fee47172 (patch) | |
tree | e066456d4ca3edf3272f3334ae27b12ea4ff0d0f | |
parent | 4da00837aca48d8fc0b33a3689390481b458cd13 (diff) |
Force UTF-8 output so that foreign characters can be displayed by Bratchbot
-rwxr-xr-x[-rw-r--r--] | blatranslate.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/blatranslate.java b/blatranslate.java index af1f402..75f8f51 100644..100755 --- a/blatranslate.java +++ b/blatranslate.java @@ -26,15 +26,19 @@ import java.io.BufferedReader; import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
public class blatranslate {
- public static void main(String[] args) throws IOException
+ public static void main(String[] args) throws IOException, UnsupportedEncodingException
{
String query = "";
String sourceLang = "?";
String targetLang = "";
String sourceString = "";
+ PrintStream out = new PrintStream(System.out, true, "UTF-8");
+
/* Build query from query or arguments, depending on whether
arguments were given. */
if (args.length == 0) {
@@ -116,18 +120,18 @@ public class blatranslate { if(results.size() > 0){
for(int i=0; i< results.size(); i++){
if (i != 0) {
- System.out.print(" | ");
+ out.print(" | ");
}
int count = i + 1;
if(langs.size() > i-1 && langs.size() > 0) {
- System.out.print("Translation ("+langs.get(i)+" to "+targetLang+"): " + results.get(i));
+ out.print("Translation ("+langs.get(i)+" to "+targetLang+"): " + results.get(i));
} else {
- System.out.print("Translation ("+sourceLang+" to "+targetLang+"): " + results.get(i));
+ out.print("Translation ("+sourceLang+" to "+targetLang+"): " + results.get(i));
}
}
} else {
- System.out.print("Error: no results.\n");
+ out.println("Error: no results.");
System.exit(1);
}
System.out.print("\n");
|