diff options
author | Bruce Momjian <bruce@momjian.us> | 2000-09-12 04:58:50 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2000-09-12 04:58:50 +0000 |
commit | 65edb541865032b5750cfe58cb8f7affbe1fc298 (patch) | |
tree | 6f7c1aae279e75e5be4dceae692c8d3b2c9386a4 /src/interfaces/jdbc/org/postgresql/PG_Stream.java | |
parent | 4f5cdadf03ae97de4fbd9ef90e15a080291b6a13 (diff) | |
download | postgresql-65edb541865032b5750cfe58cb8f7affbe1fc298.tar.gz |
Attached are a patch to allow the charset encoding used by the JDBC
driver to be set, and a description of said patch. Please refer to
the latter for more information.
William
--
William Webber william@peopleweb.net.au
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/PG_Stream.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/PG_Stream.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/PG_Stream.java b/src/interfaces/jdbc/org/postgresql/PG_Stream.java index 35bd6df364..22c41bdb3a 100644 --- a/src/interfaces/jdbc/org/postgresql/PG_Stream.java +++ b/src/interfaces/jdbc/org/postgresql/PG_Stream.java @@ -235,17 +235,22 @@ public class PG_Stream } return n; } + + public String ReceiveString(int maxsize) throws SQLException { + return ReceiveString(maxsize, null); + } /** * Receives a null-terminated string from the backend. Maximum of * maxsiz bytes - if we don't see a null, then we assume something * has gone wrong. * - * @param maxsiz maximum length of string + * @param encoding the charset encoding to use. + * @param maxsiz maximum length of string in bytes * @return string from back end * @exception SQLException if an I/O error occurs */ - public String ReceiveString(int maxsiz) throws SQLException + public String ReceiveString(int maxsiz, String encoding) throws SQLException { byte[] rst = new byte[maxsiz]; int s = 0; @@ -267,7 +272,16 @@ public class PG_Stream } catch (IOException e) { throw new PSQLException("postgresql.stream.ioerror",e); } - String v = new String(rst, 0, s); + String v = null; + if (encoding == null) + v = new String(rst, 0, s); + else { + try { + v = new String(rst, 0, s, encoding); + } catch (UnsupportedEncodingException unse) { + throw new PSQLException("postgresql.stream.encoding", unse); + } + } return v; } |