UTF-8 encoding failure

Поиск
Список
Период
Сортировка
Искать

UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:
Hi,

Is this the right place to report bugs?

The attached program creates a table with Japanese column names. When the column names are retrieved in a query using PQfname, and invalid string is returned. The invalid column names can also be seen in PGAdmin III. This only seems to happen with one (or more?) specific Japanese character.

Operating System: Windows Vista Ultimate SP2 32bit
PostgreSQL server versions: 8.4.2 and 8.3.3 both fail
libpq version: 8.3.6
Database encoding: UTF8
Client encoding:
- UTF8: does not return the same column name used to create the table.
- SJIS: "select * from table" fails with error:
    ERROR:  invalid byte sequence for encoding "UTF8": 0xe59eff
    HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

>From what I can see the character in question has the following encodings:
SJIS:     8c b4
UTF-16:     9f 53
UTF-8:     e5 8e 9f

Any chance this problem could be fixed soon?

Bye,

Martin Schäfer
Principal Software Engineer
Cadcorp
Computer Aided Development Corporation Ltd.
1 Heathcock Court, London, WC2R 0NT
martin.schaefer@cadcorp.com
www.cadcorp.com
****************************************************************************
This email is confidential and may be privileged and should not be used, read
or copied by anyone who is not the  original intended recipient. If you have
received this email in error  please inform the sender and delete it from
your mailbox or any other storage mechanism. Unless specifically stated,
nothing in this email constitutes an offer by Cadcorp and Cadcorp does not
warrant that any information contained in this email is accurate.
Cadcorp cannot accept liability for any statements made which are clearly the
sender's own and not expressly made on behalf of Cadcorp or one of its agents.
Please rely on your own virus check. No responsibility is taken by Cadcorp
for any damage arising out of any bug or virus infection.
****************************************************************************

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:
Hi,

This worked fine, as you can see in the attached result. However, I can see that my database has a different locale (English_United Kingdom.1252) from yours (C). Can this cause the problem?

Regards,

Martin 

> -----Original Message-----
> From: Hiroshi Saito [mailto:z-saito@guitar.ocn.ne.jp] 
> Sent: Friday, March 26, 2010 3:36 PM
> To: Martin Schäfer; 'Takahiro Itagaki'
> Cc: pgsql-bugs@postgresql.org
> Subject: Re: [BUGS] UTF-8 encoding failure
> 
> Hi.
> 
> Ahh ok, Would you try this.
> 
> C:\home\HIROSHI>"C:\Program 
> Files\PostgreSQL\8.4\bin\psql.exe" -f SJIS_TEST.SQL
> -p5433 postgres postgres
>                                                               
>           データベ
> ース一覧
>  \x96\xBC\x91O | \x8F\x8A\x97L\x8E | 
> \x83G\x83\x93\x83R\x81[\x83f\x83B\x83\x93\x
> 83O | \x8Fニ構x87\x8F\x87\x8F\x98 | 
> Ctype(\x95マ浬xB7\x89\x89\x8EZ\x8Eq) | \x83A\x 83N\x83Z\x83X\x8C\xA0
> ---------------+-------------------+--------------------------
> ----------
> ---------------+-------------------+--------
> ----+---------------------------+-----------------------------
> -------+--
> ----+---------------------------+-----------------------------
> -------+--
> ----+---------------------------+-----------------------------
> -------+--
> ----+---------------------------+-----------------------------
> -------+--
> ----+---------------------------+-----------------------------
> -------+--
> --------------------
>  postgres      | postgres          | UTF8
>     | C                         | C                                  |
>  template0     | postgres          | UTF8
>     | C                         | C                           
>        | =c/postgr
> es
> 
>                                                               
>        : postgres= CTc/postgres
>  template1     | postgres          | UTF8
>     | C                         | C                           
>        | =c/postgr
> es
> 
>                                                               
>        : postgres= CTc/postgres
> (3 行)
> 
> 
> UTF8
> SJIS
> psql:SJIS_TEST.SQL:5: NOTICE:  CREATE TABLE / PRIMARY KEY 
> will create implicit i ndex "漢字テーブル_pkey" for table "漢字テーブル"
> CREATE TABLE
> INSERT 0 1
> INSERT 0 1
>   へんかん  | どうですか
> ------------+------------
>  さいとう   | ひろし
>  こんにちは | ひろしです
> (2 行)
> 
> 
> DROP TABLE
> 
> ----- Original Message -----
> From: "Martin Schäfer" 
> 
> 
> > Hello Hiroshi-san,
> >
> > The only differences I found between my source file and 
> yours are the file encoding 
> > (Unicode/SJIS), different #include-s and different 
> parameters to PQsetdblogin. I had to 
> > undo the last two changes to compile and run on my machine. 
> And the changed file encoding 
> > made no difference. It still fails on my machine.
> >
> > Regards,
> >
> > Martin
> 
****************************************************************************
This email is confidential and may be privileged and should not be used, read
or copied by anyone who is not the  original intended recipient. If you have
received this email in error  please inform the sender and delete it from
your mailbox or any other storage mechanism. Unless specifically stated,
nothing in this email constitutes an offer by Cadcorp and Cadcorp does not
warrant that any information contained in this email is accurate.
Cadcorp cannot accept liability for any statements made which are clearly the
sender's own and not expressly made on behalf of Cadcorp or one of its agents.
Please rely on your own virus check. No responsibility is taken by Cadcorp
for any damage arising out of any bug or virus infection.
****************************************************************************

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:

Re: UTF-8 encoding failure

От:
Martin Schäfer <Martin.Schaefer@cadcorp.com>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:
Hi Martin-san.

Probably it is not a bug.
Does this help you?
Please see.

C:\home\HIROSHI>cl TestPostgreSQLJapanese.cpp -I"C:\Program Files\PostgreSQL\8.4
\include" "C:\Program Files\PostgreSQL\8.4\lib\libpq.lib"
Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

TestPostgreSQLJapanese.cpp
 WINVER not defined. Defaulting to 0x0600 (Windows Vista)
c:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE\afxwin1.inl(105)
: warning C4530: C++ 例外処理を使っていますが、アンワインド セマンティクスは有効
にはなりません。/EHsc を指定してください。
Microsoft (R) Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:TestPostgreSQLJapanese.exe
TestPostgreSQLJapanese.obj
"C:\Program Files\PostgreSQL\8.4\lib\libpq.lib"

C:\home\HIROSHI>set Path=%Path%;C:\Program Files\PostgreSQL\8.4\bin;

C:\home\HIROSHI>TestPostgreSQLJapanese.exe
Testing with encoding UTF-8:
NOTICE:  CREATE TABLE will create implicit sequence "蝗帛ョ誉gid_seq" for serial
column "蝗帛ョ・gid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "蝗帛ョ誉pkey" for
 table "蝗帛ョ・

Testing with encoding SJIS:
NOTICE:  CREATE TABLE will create implicit sequence "四宗_gid_seq" for serial co
lumn "四宗.gid"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "四宗_pkey" for t
able "四宗"

Press any key to exit.


Regards,
Hiroshi Saito

----- Original Message ----- 
From: "Martin Schäfer" 
To: 
Sent: Thursday, March 25, 2010 8:27 PM
Subject: [BUGS] UTF-8 encoding failure


Hi,

Is this the right place to report bugs?

The attached program creates a table with Japanese column names. When the column names are 
retrieved in a query using PQfname, and invalid string is returned. The invalid column names 
can also be seen in PGAdmin III. This only seems to happen with one (or more?) specific 
Japanese character.

Operating System: Windows Vista Ultimate SP2 32bit
PostgreSQL server versions: 8.4.2 and 8.3.3 both fail
libpq version: 8.3.6
Database encoding: UTF8
Client encoding:
- UTF8: does not return the same column name used to create the table.
- SJIS: "select * from table" fails with error:
    ERROR:  invalid byte sequence for encoding "UTF8": 0xe59eff
    HINT:  This error can also happen if the byte sequence does not match the encoding 
expected by the server, which is controlled by "client_encoding".

>From what I can see the character in question has the following encodings:
SJIS:     8c b4
UTF-16:     9f 53
UTF-8:     e5 8e 9f

Any chance this problem could be fixed soon?

Bye,

Martin Schäfer
Principal Software Engineer
Cadcorp
Computer Aided Development Corporation Ltd.
1 Heathcock Court, London, WC2R 0NT
martin.schaefer@cadcorp.com
www.cadcorp.com
****************************************************************************
This email is confidential and may be privileged and should not be used, read
or copied by anyone who is not the  original intended recipient. If you have
received this email in error  please inform the sender and delete it from
your mailbox or any other storage mechanism. Unless specifically stated,
nothing in this email constitutes an offer by Cadcorp and Cadcorp does not
warrant that any information contained in this email is accurate.
Cadcorp cannot accept liability for any statements made which are clearly the
sender's own and not expressly made on behalf of Cadcorp or one of its agents.
Please rely on your own virus check. No responsibility is taken by Cadcorp
for any damage arising out of any bug or virus infection.
****************************************************************************



--------------------------------------------------------------------------------


>
> -- 
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
> 

Re: UTF-8 encoding failure

От:
Takahiro Itagaki <itagaki.takahiro@oss.ntt.co.jp>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:
Hi.

Ahh ok, Would you try this.

C:\home\HIROSHI>"C:\Program Files\PostgreSQL\8.4\bin\psql.exe" -f SJIS_TEST.SQL
-p5433 postgres postgres
                                                                        データベ
ース一覧
 \x96\xBC\x91O | \x8F\x8A\x97L\x8E | \x83G\x83\x93\x83R\x81[\x83f\x83B\x83\x93\x
83O | \x8Fニ構x87\x8F\x87\x8F\x98 | Ctype(\x95マ浬xB7\x89\x89\x8EZ\x8Eq) | \x83A\x
83N\x83Z\x83X\x8C\xA0
---------------+-------------------+--------------------------------------------
----+---------------------------+------------------------------------+----------
--------------------
 postgres      | postgres          | UTF8
    | C                         | C                                  |
 template0     | postgres          | UTF8
    | C                         | C                                  | =c/postgr
es

                                                                     : postgres=
CTc/postgres
 template1     | postgres          | UTF8
    | C                         | C                                  | =c/postgr
es

                                                                     : postgres=
CTc/postgres
(3 行)


UTF8
SJIS
psql:SJIS_TEST.SQL:5: NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit i
ndex "漢字テーブル_pkey" for table "漢字テーブル"
CREATE TABLE
INSERT 0 1
INSERT 0 1
  へんかん  | どうですか
------------+------------
 さいとう   | ひろし
 こんにちは | ひろしです
(2 行)


DROP TABLE

----- Original Message ----- 
From: "Martin Schäfer" 


> Hello Hiroshi-san,
>
> The only differences I found between my source file and yours are the file encoding 
> (Unicode/SJIS), different #include-s and different parameters to PQsetdblogin. I had to 
> undo the last two changes to compile and run on my machine. And the changed file encoding 
> made no difference. It still fails on my machine.
>
> Regards,
>
> Martin

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:

Re: UTF-8 encoding failure

От:
"Hiroshi Saito" <z-saito@guitar.ocn.ne.jp>
Дата:
FAQ