X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A3A74476315 for ; Mon, 5 May 2003 12:49:31 -0400 (EDT) Received: from lubitsch.akademie.de (ns.akademie.de [62.165.4.3]) by postgresql.org (Postfix) with ESMTP id D4E42476085 for ; Mon, 5 May 2003 12:49:30 -0400 (EDT) Received: from [62.165.4.177] (helo=kidman.akademie1.de) by lubitsch.akademie.de with esmtp (Exim 3.33 #2) id 19Cj9j-0003f2-00; Mon, 05 May 2003 18:49:35 +0200 Content-Type: text/plain; charset="iso-8859-1" From: Ian Barwick To: Achilleus Mantzios Subject: Re: UNICODE and SQL Date: Mon, 5 May 2003 18:48:45 +0200 User-Agent: KMail/1.4.3 Cc: Marco Roda , References: In-Reply-To: MIME-Version: 1.0 Message-Id: <200305051848.45893.barwick@gmx.net> Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-38.9 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/57 X-Sequence-Number: 13222 On Monday 05 May 2003 22:24, Achilleus Mantzios wrote: > On Mon, 5 May 2003, Ian Barwick wrote: > > On Monday 05 May 2003 15:34, Marco Roda wrote: > > > Hallo, > > > > > > I need to use SQL to insert some language specific characters into > > > tables. In particular I am using German and Croatian specific > > > characters. The database is created with UNICODE encoding. > > > For instance, when trying to run from psql: > > > > > > INSERT INTO test VALUES (1,'Urlaubslite f=FCr n=E4chstes Jahr'); > > > > > > I get the following error: > > > > > > ERROR: Invalid UNICODE character sequence found (0xfc7220) > > > > > > because of '=FC' and '=E4'. > > > > What is your psql client encoding set to? Possibly you need > > to set it to LATIN1. or LATIN2 (?) for the Croatian characters. > The UTF8 version of Latin1 is Latin1 itself, > but german and iso8859-2 serbocroatian are > non Latin1 (high ASCII) chars. In PostgreSQL "LATIN1" is ISO 8859-1, see: http://www.postgresql.org/docs/view.php?version=3D7.3&idoc=3D0&file=3Dmulti= byte.html Unicode Latin 1 (characters 160-255) happens to be the same as ISO 8859-1, but in UTF-8 is represented as 2 bytes. Setting psql's \encoding to LATIN1 will convert the client's 8-bit ISO 8859= -1=20 characters (presuming this is the case) to UTF-8. unitest=3D# \encoding unicode unitest=3D# INSERT INTO test VALUES (1,'Urlaubslite f=FCr n=E4chstes Jahr'); ERROR: Invalid UNICODE character sequence found (0xfc7220) unitest=3D# \encoding latin1=20 unitest=3D# INSERT INTO test VALUES (1,'Urlaubslite f=FCr n=E4chstes Jahr'); INSERT 19134 1 unitest=3D# select * from test; id | val=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ----+------------------------------- 1 | Urlaubslite f=FCr n=E4chstes Jahr (1 row) unitest=3D# \encoding unicode unitest=3D# select * from test; id | val=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ----+------------------------------- 1 | Urlaubslite f=C3=BCr n=C3=A4chstes Jahr (1 row) Ian Barwick barwick@gmx.net