Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 574F79FA267 for ; Fri, 19 Oct 2007 21:21:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 79919-04 for ; Fri, 19 Oct 2007 21:21:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id CED579F9FD8 for ; Fri, 19 Oct 2007 21:21:07 -0300 (ADT) Received: from 222-154-138-58.jetstream.xtra.co.nz ([222.154.138.58] helo=[10.1.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Ij25N-0008JS-LD; Sat, 20 Oct 2007 13:21:01 +1300 Message-ID: <471949F9.8020304@opencloud.com> Date: Sat, 20 Oct 2007 13:21:13 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Joao.Pires@iscte.pt CC: pgsql-jdbc@postgresql.org Subject: Re: PostgreSQL JDBC Driver versus Encoding References: <004301c812a1$7a8ee980$dc4c0a0a@ci.iscte.intranet> In-Reply-To: <004301c812a1$7a8ee980$dc4c0a0a@ci.iscte.intranet> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/117 X-Sequence-Number: 17689 Joćo Paulo Pires wrote: > I have a PostgreSQL database which encoding is SQL_ASCII. This is the cause of your problem. SQL_ASCII provides essentially no encoding information at all, so the JDBC driver does not know how to translate between the database and Java's internal UTF-16 representation. If you are going to be inserting anything other than 7-bit-ASCII text into it, you are going to have problems. If you can, try using a database encoding that can represent the data you are inserting. UTF8 / UNICODE is probably a good choice unless you have special requirements. See http://www.postgresql.org/docs/8.2/static/multibyte.html especially the bit that says: > The SQL_ASCII setting behaves considerably differently from the other settings. When the server character set is SQL_ASCII, the server interprets byte values 0-127 according to the ASCII standard, while byte values 128-255 are taken as uninterpreted characters. No encoding conversion will be done when the setting is SQL_ASCII. Thus, this setting is not so much a declaration that a specific encoding is in use, as a declaration of ignorance about the encoding. In most cases, if you are working with any non-ASCII data, it is unwise to use the SQL_ASCII setting, because PostgreSQL will be unable to help you by converting or validating non-ASCII characters. -O