Re: Unicode problem ???

From: "Stijn Vanroye" <s(dot)vanroye(at)farcourier(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Cc: "Priem, Alexander" <ap(at)cict(dot)nl>
Subject: Re: Unicode problem ???
Date: 2004-04-21 13:15:26
Message-ID: 71E201BE5E881C46811BA160694C5FCB046725@fs1000.farcourier.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Hi everyone,
>
> I have a PostgreSQL 7.4 database running, which was initdb-ed
> using standard
> (SQL_ASCII) encoding, with -lc-collate=C option set.
>
> Everything is running fine, but I just discovered something
> funny. If text
> containing characters like ë is inserted into the database
> (text field), the
> inserting goes fine. When I view this data using phpPgAdmin
> (v3.2.1) it
> looks fine, including these special characters.
>
> HOWEVER, when I get this data from within a Delphi application, using
> psqlODBC (07.03.0200), the special characters get corrupted (ë becomes
> something like ë). It seems to be a unicode problem.
>
> What do you think, should I re-create the database using
> UNICODE encoding?
> I'd like to know beforehand if this will solve the problem,
> since I do not
> want to recreate the database just to find out that it does
> not fix things.
>
> Or does the problem involve psqlODBC. I looked into some of
> its settings,
> but I can't find anything that involves character encoding...
>
> I hope someone can give me a pointer here.
>
> Thanks in advance,
> Alexander Priem
> The Netherlands.
>
I'm a Delphi (7 Enterprise) user myself. I've ran into that sort of encoding problems to. On the postgres backend I use UNICODE.

I'll tell you what I know, I hope it helps a bit.
First off: there seems to be a difference between the datatypes string and widestring in Delphi. widestring is recommended for use with 'wide byte strings' (or something like that), for example UNICODE. string variables however can't be trusted for the full 100% in that case. I don't know exactly how it worked, but I'm sure some browsing in the Delphi Help and other rescources will explain things.

Second: I know that in my case I have to set the CLIENT_ENCODING TO 'LATIN1' in my odbc connect string to make sure that all the characters are translated correct.

I'm sorry that I can't be more specific about these things since I don't remember exactly WHY these things are done, but I do know they help :-) This was all set-up and figured out by one of my colleagues a while ago. I was not excactly into the database itself, but restricted my work to delphi coding en general development.
Therefore I hope that someone else can shed more light onto the matter so I can learn a bit too :-)

Kind Regards,

Stijn Vanroye.

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-04-21 13:22:39 Re: Unicode problem ???
Previous Message Joe Lester 2004-04-21 13:04:35 Re: Connection reset by peer