Thread: Character encoding problem using Tcl

Character encoding problem using Tcl

From
"Johann Woeckinger"
Date:
I use PostgreSQL 7.0.3 on Linux (i386) platform, Tcl 8.3 is installed.

When entering National special characters (e.g. accented german
characters) by use of psql into a database, all seems to be ok., the special
characters appear correct on queries (locale seems to work well in this case).

But when using a Tcl-based interface (e.g. pgaccess or home made tcl
based programs) to insert such characters into a table, they are not correct
displayed on queries by use of psql - they appear as two 'unreadable'
characters (they appear correct in queries done by the tcl application).

I tried to add multibyte support to postgresql, but still the same result.
How to solve this problem?

Johann
==========================================================
E-Mail: johann.woeckinger@epluse.at
        Privat: woeckinger.johann@utanet.at
Tel. 07235/605-263 (Firma), 07235/65993 (privat)
Fax. 07235/605-383 (Firma)
Adresse/Firma: E+E Elektronik
               Dr. Johann Wöckinger
               Leiter Fertigung Systeme
               Langwiesen 7
               A-4210 Engerwitzdorf

Re: Character encoding problem using Tcl

From
Tom Lane
Date:
"Johann Woeckinger" <johann.woeckinger@epluse.at> writes:
> But when using a Tcl-based interface (e.g. pgaccess or home made tcl
> based programs) to insert such characters into a table, they are not correct
> displayed on queries by use of psql - they appear as two 'unreadable'
> characters (they appear correct in queries done by the tcl application).

Hm.  Tcl 8 uses Unicode (UTF-8) representation internally.  It sounds
like the Unicode representation is getting sent straight to the database
rather than being converted into the character set the backend is
expecting.

We could fix this in libpgtcl if we could figure out what Tcl encoding
corresponds to the character set the backend is using.  I'm not sure
if that's easy or hard.

Alternatively, building Postgres with multibyte support and creating
your database with UNICODE encoding ought to work.

            regards, tom lane

Re: Character encoding problem using Tcl

From
"Oliver Elphick"
Date:
Tom Lane wrote:
  >"Johann Woeckinger" <johann.woeckinger@epluse.at> writes:
  >> But when using a Tcl-based interface (e.g. pgaccess or home made tcl
  >> based programs) to insert such characters into a table, they are not corre
      >ct
  >> displayed on queries by use of psql - they appear as two 'unreadable'
  >> characters (they appear correct in queries done by the tcl application).
  >
  >Hm.  Tcl 8 uses Unicode (UTF-8) representation internally.  It sounds
  >like the Unicode representation is getting sent straight to the database
  >rather than being converted into the character set the backend is
  >expecting.
  >
  >We could fix this in libpgtcl if we could figure out what Tcl encoding
  >corresponds to the character set the backend is using.  I'm not sure
  >if that's easy or hard.
  >
  >Alternatively, building Postgres with multibyte support and creating
  >your database with UNICODE encoding ought to work.


Tcl changed its behaviour at 8.1.  If you use 8.0, it will probably
work.

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "And the angel said to her, " Do not be afraid, Mary;
      for you have found favor with God. And behold, you
      will conceive in your womb, and bear a son, and you
      shall name Him Jesus."       Luke 1:30,31