Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A47EB63294D for ; Mon, 15 Feb 2010 21:44:40 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 42161-06 for ; Tue, 16 Feb 2010 01:44:13 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.turbonet.com (mail.turbonet.com [216.98.224.8]) by mail.postgresql.org (Postfix) with ESMTP id 71E116322D6 for ; Mon, 15 Feb 2010 21:44:29 -0400 (AST) Received: from [192.168.0.107] ([76.178.161.195]) by mail.turbonet.com (Cactus Mail Server v9.4.0) with ASMTP id YDI45322; Mon, 15 Feb 2010 17:44:22 -0800 Message-ID: <4B79F86A.1070702@cedarstump.com> Date: Mon, 15 Feb 2010 17:44:10 -0800 From: Luke Coldiron User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Hiroshi Inoue CC: pgsql-odbc@postgresql.org Subject: Re: invalid byte sequence for encoding "UTF8" References: <66b852d2872c0c26d559b0dc6ad00307@cedarstump.com> <4B79EE13.1030906@tpf.co.jp> In-Reply-To: <4B79EE13.1030906@tpf.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 201002/11 X-Sequence-Number: 10198 Hiroshi Inoue wrote: > luke wrote: >> I am running into a difference in behavior that I think is related to >> the psqlODBC driver between Windows and Linux. On Windows x86 using >> the Windows ODBC manager and psqlODBC 8.4.2 ANSI driver I have some >> C++ code that executes the following SQL statements and inserts into >> a Windows x86 PostgreSQL 8.4.2 database. >> >> CREATE TABLE luke_test(a TEXT); >> INSERT INTO luke_test (a) VALUES('ý'); >> INSERT INTO luke_test (a) VALUES('þ'); >> INSERT INTO luke_test (a) VALUES('ÿ'); >> SELECT * FROM luke_test; >> --ý >> --þ >> --ÿ >> DROP TABLE luke_test; >> >> Where the value being insered is a single character byte. This seems >> to work fine in Windows. I am not wanting to treat the bytes with >> there 8th bit set as multi-byte characters. >> >> However, if I compile and run the same C++ code on Linux x64 using >> unixODBC 2.2.15pre ODBC manager and psqlODBC 8.4.2 ANSI driver >> inserting into the before mentioned Windows x86 PostreSQL 8.4.2 >> database I get different behavior. >> >> CREATE TABLE luke_test(a TEXT); >> INSERT INTO luke_test (a) VALUES('ý'); >> Error executing "INSERT INTO luke_test (a) VALUES('ý');": ERROR: >> invalid byte sequence for encoding "UTF8": 0xfd; >> Error while executing the query >> INSERT INTO luke_test (a) VALUES('þ'); >> Error executing "INSERT INTO luke_test (a) VALUES('þ');": ERROR: >> invalid byte sequence for encoding "UTF8": 0xfe; >> Error while executing the query >> INSERT INTO luke_test (a) VALUES('ÿ'); >> Error executing "INSERT INTO luke_test (a) VALUES('ÿ');": ERROR: >> invalid byte sequence for encoding "UTF8": 0xff; >> Error while executing the query >> SELECT * FROM luke_test; >> DROP TABLE luke_test; >> >> Which leads me to believe that my environment on Linux is trying to >> treat the character bytes as multi-byte characters. > > I have tried SET client_encoding='ANSI_SQL' before I execute the > inserts and that does not seem to help the situation. > > Please try SET client_encoding='LATIN1' . That worked! Thank you! > > regards, > Hiroshi Inoue > > > Can anyone help explain the difference in behavior that I am seeing > and suggest a workaround that does not involve encoding the character > bytes as UTF8. > > > > ------------------------------------------------------------------------ > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.733 / Virus Database: 271.1.1/2688 - Release Date: 02/14/10 11:35:00 > >