unicode and varchar - Mailing list pgsql-general

From Michael Wimmer
Subject unicode and varchar
Date
Msg-id 4141a4f7$0$13272$91cee783@newsreader02.highway.telekom.at
Whole thread Raw
Responses Re: unicode and varchar  (Ian Barwick <barwick@gmail.com>)
List pgsql-general
Hi all,

I have a problem when inserting into a varchar field via jdbc.

Using to bytes makes the varchar fields shorten.

Example: with 7.4.5. on Linux

create table test(charfield varchar(5));
insert into test(charfield) values('abcde');
insert into test(charfield) values('üö');

select bit_length(charfield), length(charfield), charfield from test

  bit_length     length     charfield
  -------------  ---------  ------------
  40             5          abcde
  32             4          üö

insert into test(charfield) values('üäö');
  Error: ERROR:  value too long for type character varying(5)

Doing the same on Windows with the fresh 8.0 beta 2 shows a different
behaviour.


create table test(charfield varchar(5));
insert into test(charfield) values('abcde');
insert into test(charfield) values('üöüöä');

select bit_length(charfield), length(charfield), charfield from test

  bit_length     length     charfield
  -------------  ---------  ------------
  40             5          abcde
  80             5          üöüöä

'length' seems to account the 16 bit character length.


Is there a way to make this work in 7.4.x too?
May problem is that we are in a rush to do a port of our application
from informix and I will not be able to wait until 8.0 will be released.

BTW, both database servers where queried with the same JDBC driver
(version).

Best regards,

Michael

pgsql-general by date:

Previous
From: Vic Cekvenich
Date:
Subject: Text search performance vs MY SQL
Next
From: nboutelier@hotmail.com (Nick)
Date:
Subject: What is the postgres version of mysql's "ON DUPLICATE KEY"