Forgotten file.

Add character sets to the server

PR:		27846
Submitted by:	Palle Girgensohn <girgen@partitur.se>
This commit is contained in:
James E. Housley 2001-06-04 11:53:50 +00:00
parent 80c544e830
commit 9811a25b6c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=43486
14 changed files with 714 additions and 0 deletions

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}

View file

@ -0,0 +1,51 @@
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- src/interfaces/jdbc/org/postgresql/Connection.java 2001/01/31 08:26:01 1.14
+++ src/interfaces/jdbc/org/postgresql/Connection.java 2001/06/01 20:57:58 1.16
@@ -10,7 +10,7 @@
import org.postgresql.util.*;
/**
- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
+ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@@ -267,7 +267,8 @@
//
firstWarning = null;
- java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
+ java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; " +
+ "select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end");
String dbEncoding = null;
//retrieve DB properties
@@ -307,9 +308,23 @@
} else if (dbEncoding.equals("EUC_TW")) {
dbEncoding = "EUC_TW";
} else if (dbEncoding.equals("KOI8")) {
- dbEncoding = "KOI8_R";
+ // try first if KOI8_U is present, it's a superset of KOI8_R
+ try {
+ dbEncoding = "KOI8_U";
+ "test".getBytes(dbEncoding);
+ }
+ catch(UnsupportedEncodingException uee) {
+ // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
+ dbEncoding = "KOI8_R";
+ }
+
} else if (dbEncoding.equals("WIN")) {
dbEncoding = "Cp1252";
+ } else if (dbEncoding.equals("UNKNOWN")) {
+ //This isn't a multibyte database so we don't have an encoding to use
+ //We leave dbEncoding null which will cause the default encoding for the
+ //JVM to be used
+ dbEncoding = null;
} else {
dbEncoding = null;
}