Обсуждение: unicode and varchar

Поиск
Список
Период
Сортировка

unicode and varchar

От
Michael Wimmer
Дата:
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

Re: unicode and varchar

От
Ian Barwick
Дата:
On Fri, 10 Sep 2004 14:57:18 +0200, Michael Wimmer <newsgroup1@ecom.at> wrote:
(...)
> 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.

What encoding does the 7.4.x database have?

Ian Barwick

Re: unicode and varchar

От
"michael.wimmer"
Дата:
Thanks for bringing me on the track.

I recreated the database with encoding=utf8 and downloaded the latest
build of the driver (215). Both together made it work.

Best regards,

Michael

Ian Barwick wrote:

> On Fri, 10 Sep 2004 14:57:18 +0200, Michael Wimmer <newsgroup1@ecom.at> wrote:
> (...)
>
>>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.
>
>
> What encoding does the 7.4.x database have?
>
> Ian Barwick
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>