Thread: pgtcl and umlaut

pgtcl and umlaut

From
Gerd Scheidhauer
Date:
Hello,

I'm using postgresql 7.0.2 on a PC running Linux (Mandrake 7.2). I'm
developing a application using the Tcl/Tk binding pgtcl (included in the
postgresql distribution).

I have problems with the german umlaut (ÄÖÜ): it is possible to insert and
read strings containing umlaut letters in a pgtcl application, but when the
database sorts the table, the sort order is wrong:

 A Ä Ö Ü B C ...

instead of

 A Ä B C ... O Ö P ... U Ü V ...

The database dump with otion -d (proper insert strings) prints 

 \303\204   for Ä
 \303\226   for Ö
 \303\234   for Ü

I tried differend encodings in the database (UNICODE, LATIN1, SQL_ASCII) as
well as in tcl (unicode, iso8859-1) but there was no impact on the sort 
result.

You find a pgtcl script attached to this mail that demonstrates the problem.
Before starting the script you have to create a database:

  createdb -E UNICODE sort_umlaut

then you have to run the script (pgtclsh must be installed in /usr/bin,
otherwise edit the first line of the script):

  chmod u+x problem.tcl
  ./problem.tcl

The script prints the sorted table. Afterwards you can print the contents of
the database:

  pg_dump -d sort_umlaut

Maybe somebody has a solution for the problem ;-)

Thanks in advance,
Gerd

-- 
Gerd Scheidhauer
http://www.gerdscheidhauer.de
phone:+49 721 722 34 16

Re: pgtcl and umlaut

From
Tatsuo Ishii
Date:
I'm not sure what version of Tcl are you using, but I guess it's a
general problem of Tcl >= 8.1. The only solution I could imagine so
far is down grading Tcl to 8.0.
--
Tatsuo Ishii

> I'm using postgresql 7.0.2 on a PC running Linux (Mandrake 7.2). I'm
> developing a application using the Tcl/Tk binding pgtcl (included in the
> postgresql distribution).
> 
> I have problems with the german umlaut (ÄÖÜ): it is possible to insert and
> read strings containing umlaut letters in a pgtcl application, but when the
> database sorts the table, the sort order is wrong:
> 
>  A Ä Ö Ü B C ...
> 
> instead of
> 
>  A Ä B C ... O Ö P ... U Ü V ...
> 
> The database dump with otion -d (proper insert strings) prints 
> 
>  \303\204   for Ä
>  \303\226   for Ö
>  \303\234   for Ü
> 
> I tried differend encodings in the database (UNICODE, LATIN1, SQL_ASCII) as
> well as in tcl (unicode, iso8859-1) but there was no impact on the sort 
> result.
> 
> You find a pgtcl script attached to this mail that demonstrates the problem.
> Before starting the script you have to create a database:
> 
>   createdb -E UNICODE sort_umlaut
> 
> then you have to run the script (pgtclsh must be installed in /usr/bin,
> otherwise edit the first line of the script):
> 
>   chmod u+x problem.tcl
>   ./problem.tcl
> 
> The script prints the sorted table. Afterwards you can print the contents of
> the database:
> 
>   pg_dump -d sort_umlaut
> 
> Maybe somebody has a solution for the problem ;-)
> 
> Thanks in advance,
> Gerd
> 
> -- 
> Gerd Scheidhauer
> http://www.gerdscheidhauer.de
> phone:+49 721 722 34 16


Re: pgtcl and umlaut

From
Tom Lane
Date:
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> I'm not sure what version of Tcl are you using, but I guess it's a
> general problem of Tcl >= 8.1. The only solution I could imagine so
> far is down grading Tcl to 8.0.

I've forgotten the details of this problem, but I do remember that the
newer Tcl versions want Unicode (UTF-8) representation.  Would it work
to build Postgres with MULTIBYTE support and set client encoding to
UTF-8?
        regards, tom lane


Re: pgtcl and umlaut

From
Tatsuo Ishii
Date:
> > I'm not sure what version of Tcl are you using, but I guess it's a
> > general problem of Tcl >= 8.1. The only solution I could imagine so
> > far is down grading Tcl to 8.0.
> 
> I've forgotten the details of this problem, but I do remember that the
> newer Tcl versions want Unicode (UTF-8) representation.  Would it work
> to build Postgres with MULTIBYTE support and set client encoding to
> UTF-8?

Sure. But he is using 7.0, and he needs to upgrade to 7.1 to have
UTF-8 <--> LATIN1 conversion.
--
Tatsuo Ishii