Re: Unicode problem ??? - Mailing list pgsql-general

From Priem, Alexander
Subject Re: Unicode problem ???
Date
Msg-id 2A07EC2D0BC2774AAD6F74769F60D52A083301@ahmose.cict_ad.nl
Whole thread Raw
In response to Unicode problem ???  ("Priem, Alexander" <ap@cict.nl>)
List 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.

I just tried something else. If I use SQL Explorer (A Borland tool for
manipulating/viewing databases through DSN's) to look at this database,
using the same (psqlODBC) DSN, I also get the wrong characters. So it seems
Delphi doesn't have anything to do with it.

On the other hand, SQL Explorer is also a Borland product...

But I also just tried to view this field as a widestring. I queried the
database and used ShowMessage(VarToWideStr(rs.Fields[1].Value)) to view the
text. Didn't help...

I also tried to change the client_encoding via SQL. I just gave a "set
client_encoding to 'unicode'" command, followed by the command to retrieve
the text. Also didn't help. "set client_encoding to 'latin1'" didn't help
either.

Is this the correct way to change the encoding or do I needd to rebuild the
database? Maybe I am not really changing the encoding this way???

Alexander Priem.

pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Unicode problem ???
Next
From: Bruce Momjian
Date:
Subject: Re: [OT] Tom's/Marc's spam filters?