Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6EE0C63342A for ; Fri, 24 Jul 2009 07:31:14 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 29756-08 for ; Fri, 24 Jul 2009 10:30:57 +0000 (UTC) X-Greylist: delayed 00:26:48.738669 by SQLgrey-1.7.6 Received: from ikoffice.de (ikoffice.de [81.169.166.92]) by mail.postgresql.org (Postfix) with ESMTP id 0F85E6323B6 for ; Fri, 24 Jul 2009 07:30:46 -0300 (ADT) Received: from p5481c7fb.dip.t-dialin.net ([84.129.199.251] helo=[192.168.1.16]) by ikoffice.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.66) (envelope-from ) id 1MUHd1-0005uw-Er; Fri, 24 Jul 2009 12:03:52 +0200 Message-ID: <4A698706.4040502@ikoffice.de> Date: Fri, 24 Jul 2009 12:03:50 +0200 From: Daniel Migowski User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Markus Kickmaier CC: pgsql-jdbc@postgresql.org Subject: Re: Encoding from CopyManager.copyIn() References: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at> In-Reply-To: <9709844.92821248280225595.JavaMail.root@donald.apus.co.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Bar: - X-Spam-Score-Int: -17 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/56 X-Sequence-Number: 19824 The PrintWriter has another constructor where you can give "UTF8" as Encoding. Default is platform encoding (usually "Win1252" for me in Germany). Best, Daniel Migowski Markus Kickmaier schrieb: > Hello, > > I'm using the copyIn() function of the CopyManager. It works fine until I don't use an "umlaut" like ü. Then i get an PSQLException: > > org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0xfc > > My code looks like follows: > > ByteArrayOutputStream output = new ByteArrayOutputStream(); > PrintWriter writer = new PrintWriter(output); > writer.println("abcüäö"); > writer.flush(); > ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray()); > long result = ((PGConnection) con_).getCopyAPI().copyIn(statement, input); > > After searching at google i found out that this is an encoding problem. The database doesn't know what charset I'm using. > > Any suggestion how i can specify the encoding i want to use? > > BR, Markus > >