Index: /main/trunk/greenstone2/common-src/src/jdbmedit/Jdb2Txt.java
===================================================================
--- /main/trunk/greenstone2/common-src/src/jdbmedit/Jdb2Txt.java	(revision 21402)
+++ /main/trunk/greenstone2/common-src/src/jdbmedit/Jdb2Txt.java	(revision 21403)
@@ -30,4 +30,7 @@
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 import java.util.Properties;
 
@@ -40,8 +43,25 @@
     HTree          hashtable_;
 
+    static private PrintWriter utf8out = null;
+
+    static
+    {
+        try {
+            OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
+            utf8out = new PrintWriter(osw, true);
+        }
+        catch (UnsupportedEncodingException e) {
+            System.out.println(e);
+        }
+    }
 
     public Jdb2Txt(String db_filename)
 	throws IOException
     {
+	if (db_filename.endsWith(".jdb")) {
+	    // remove file extension as JDBM does not expect it
+	    db_filename = db_filename.substring(0,db_filename.length()-4);
+	}
+
         // create or open a record manager
         Properties props = new Properties();
@@ -71,8 +91,8 @@
         while (key != null) {
             val = (String) hashtable_.get(key);
-            System.out.println("[" + key + "]");
-            System.out.println(val);
+            utf8out.println("[" + key + "]");
+            utf8out.println(val);
 	    // 70 hypens
-	    System.out.println("----------------------------------------------------------------------");
+	    utf8out.println("----------------------------------------------------------------------");
             key = (String) iter.next();
         }
Index: /main/trunk/greenstone2/common-src/src/jdbmedit/JdbGet.java
===================================================================
--- /main/trunk/greenstone2/common-src/src/jdbmedit/JdbGet.java	(revision 21402)
+++ /main/trunk/greenstone2/common-src/src/jdbmedit/JdbGet.java	(revision 21403)
@@ -30,4 +30,7 @@
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 import java.util.Properties;
 
@@ -35,4 +38,16 @@
 public class JdbGet
 {
+    static private PrintWriter utf8out = null;
+
+    static
+    {
+        try {
+            OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
+            utf8out = new PrintWriter(osw, true);
+        }
+        catch (UnsupportedEncodingException e) {
+            System.out.println(e);
+        }
+    }
 
     public static void print_usage()
@@ -56,5 +71,5 @@
             JdbmAPI jdbm_api = new JdbmAPI(dbname,true);
             String val = jdbm_api.get(key);
-	    System.out.println(val);
+	    utf8out.println(val);
 
 	    jdbm_api.close();
Index: /main/trunk/greenstone2/common-src/src/jdbmedit/JdbKeys.java
===================================================================
--- /main/trunk/greenstone2/common-src/src/jdbmedit/JdbKeys.java	(revision 21402)
+++ /main/trunk/greenstone2/common-src/src/jdbmedit/JdbKeys.java	(revision 21403)
@@ -25,4 +25,7 @@
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 import java.util.Properties;
 import java.util.ArrayList;
@@ -35,4 +38,17 @@
 public class JdbKeys
 {
+    static private PrintWriter utf8out = null;
+
+    static
+    {
+        try {
+            OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
+            utf8out = new PrintWriter(osw, true);
+        }
+        catch (UnsupportedEncodingException e) {
+            System.out.println(e);
+        }
+    }
+
     public static void print_usage()
     {
@@ -51,13 +67,12 @@
 
         try {
-
             JdbmAPI jdbm_api = new JdbmAPI(dbname,true);
-
+	    
 	    ArrayList keys = jdbm_api.get_keys();
-		    
+	    
 	    int keys_len = keys.size();
 	    for (int i=0; i<keys_len; i++) {
 		String key = (String) keys.get(i);
-		System.out.println(key);
+		utf8out.println(key);
 	    }
 
Index: /main/trunk/greenstone2/common-src/src/jdbmedit/JdbmAPI.java
===================================================================
--- /main/trunk/greenstone2/common-src/src/jdbmedit/JdbmAPI.java	(revision 21402)
+++ /main/trunk/greenstone2/common-src/src/jdbmedit/JdbmAPI.java	(revision 21403)
@@ -27,4 +27,7 @@
 import java.io.InputStreamReader;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
 
 import java.util.Properties;
@@ -45,7 +48,25 @@
     HTree          hashtable_;
 
+    static private PrintWriter utf8out = null;
+
+    static
+    {
+        try {
+            OutputStreamWriter osw = new OutputStreamWriter(System.out, "UTF-8");
+            utf8out = new PrintWriter(osw, true);
+        }
+        catch (UnsupportedEncodingException e) {
+            System.out.println(e);
+        }
+    }
+
     public JdbmAPI(String db_filename,boolean must_exist)
 	throws IOException
     {
+	if (db_filename.endsWith(".jdb")) {
+	    // remove file extension as JDBM does not expect it
+	    db_filename = db_filename.substring(0,db_filename.length()-4);
+	}
+
         // create or open a record manager
         Properties props = new Properties();
@@ -197,5 +218,5 @@
 	    JdbmAPI jdbm_api = new JdbmAPI(dbname);
 
-	    InputStreamReader isr=new InputStreamReader(System.in);
+	    InputStreamReader isr=new InputStreamReader(System.in,"UTF-8");
 	    BufferedReader brin = new BufferedReader(isr);
 
@@ -208,9 +229,9 @@
 
 		    int keys_len = keys.size();
-		    System.out.println(keys_len);
+		    utf8out.println(keys_len);
 
 		    for (int i=0; i<keys_len; i++) {
 			String key = (String) keys.get(i);
-			System.out.println(key);
+			utf8out.println(key);
 		    }
 		}
@@ -221,6 +242,6 @@
 			if (cmd.equals("Get")) {
 			    String val = jdbm_api.get(key);
-			    System.out.println(val.length());
-			    System.out.println(val);
+			    utf8out.println(val.length());
+			    utf8out.println(val);
 			}
 			else {
Index: /main/trunk/greenstone2/common-src/src/jdbmedit/Txt2Jdb.java
===================================================================
--- /main/trunk/greenstone2/common-src/src/jdbmedit/Txt2Jdb.java	(revision 21402)
+++ /main/trunk/greenstone2/common-src/src/jdbmedit/Txt2Jdb.java	(revision 21403)
@@ -26,4 +26,8 @@
 import java.io.BufferedInputStream;
 import java.io.InputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.util.Properties;
 
 import jdbm.RecordManager;
@@ -32,7 +36,4 @@
 import jdbm.htree.HTree;
 
-import java.io.IOException;
-import java.util.Properties;
-
 
 public class Txt2Jdb
@@ -47,4 +48,9 @@
 	throws IOException
     {
+	if (db_filename.endsWith(".jdb")) {
+	    // remove file extension as JDBM does not expect it
+	    db_filename = db_filename.substring(0,db_filename.length()-4);
+	}
+
         // create or open a record manager
         Properties props = new Properties();
@@ -75,8 +81,9 @@
     // Assumes InputStream is a file or standard-in  
     // (no some other form of IO mapped device)
-    public boolean eof(InputStream is) 
+    //public boolean eof(InputStream is) 
+    public boolean eof(int c) 
 	throws IOException
     {
-	return (is.available() == 0);
+	return (c == -1);
     }
 
@@ -95,8 +102,10 @@
 	boolean delkey = false;
 
-	BufferedInputStream bis = new BufferedInputStream(System.in);
-	
+
+	InputStreamReader isr = new InputStreamReader(System.in,"UTF-8");
+	BufferedReader bis = new BufferedReader(isr);
+
 	int c = bis.read();
-	while (!eof(bis)) {
+	while (!eof(c)) {
 	    num_dashes = 0;
 	    key = new StringBuffer();
@@ -106,10 +115,10 @@
 	    
 	    // scan for first occurrence of [
-	    while (!eof(bis) && c != '[') {
-		c = bis.read();
-	    }
-
-	    
-	    if (!eof(bis)) {
+	    while (!eof(c) && c != '[') {
+		c = bis.read();
+	    }
+
+	    
+	    if (!eof(c)) {
 		c = bis.read(); // skip [
 	    }
@@ -117,10 +126,10 @@
 	    
 	    // now look for closing ], building up 'key' as we go
-	    while (!eof(bis) && c != ']') {
+	    while (!eof(c) && c != ']') {
 		key.append ((char)c);
 		c = bis.read();
 	    }
 	    
-	    if (!eof(bis)) {
+	    if (!eof(c)) {
 		// most likely an eol char, but if '-', then signifies record
 		// is to be deleted, not added
@@ -134,5 +143,5 @@
 	    }
 
-	    while (!eof(bis) && (c == '\n' || c == '\r')) {
+	    while (!eof(c) && (c == '\n' || c == '\r')) {
 		c = bis.read();
 	    }
@@ -140,5 +149,5 @@
 	    // look for 70 dashes
 	    tmp = new StringBuffer();
-	    while (!eof(bis) && (num_dashes < 70)) {
+	    while (!eof(c) && (num_dashes < 70)) {
 		if (c == '\n') {
 		    tmp.append((char)c);
