From: Lew <noone@lewscanon.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Using java.lang.Character for "char" data type
Date: Fri, 21 May 2010 21:11:52 -0400
Message-ID: <ht7b0f$l6j$1@news.albasani.net> (raw)
In-Reply-To: <alpine.BSO.2.00.1005211813180.22460@leary.csoft.net>
References: <AANLkTinKef9bhdEhYMMzxiRLKUXtGt_cUOnIPT5sibXI@mail.gmail.com>
<alpine.BSO.2.00.1005211813180.22460@leary.csoft.net>
Kris Jurka wrote:
> It would be possible to support setObject for a Character, but be aware
> that "char" is not a character long, it's a byte long, so it will fail
> on multibyte characters.
I'm a little confused. When you say "char" is a byte long, are you referring
to the SQL type or the Java type? I'm used to seeing the Java type expressed
in lower case and the SQL type in upper case, so please pardon my confusion.
The Java 'char' type is 16 bits wide.
Doesn't the width of the SQL "CHAR" depend on the encoding?
Otherwise how does it handle, say, UTF-8 when you tell the DB to use that?
To put it another way, suppose I enter a String that contains, say, 24 UTF-8
characters, some of which require multibyte encodings, and try to jam it into
a "CHAR(24)" column or a "VARCHAR(24)" column. Will that cause trouble?
The documentation for CHAR and VARCHAR at
<http://www.postgresql.org/docs/8.4/interactive/datatype-character.html;
says
"SQL defines two primary character types: character varying(n) and
character(n), where n is a positive integer. Both of these types can store
strings up to n characters (not bytes) in length."
That seems to contradict what you said.
--
Lew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: noone@lewscanon.com
Subject: Re: Using java.lang.Character for "char" data type
In-Reply-To: <ht7b0f$l6j$1@news.albasani.net>
References: <AANLkTinKef9bhdEhYMMzxiRLKUXtGt_cUOnIPT5sibXI@mail.gmail.com> <alpine.BSO.2.00.1005211813180.22460@leary.csoft.net> <ht7b0f$l6j$1@news.albasani.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox