Re: Re: Error When Trying to Use Npgsql to COPY into a PostgreSQL Database - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Re: Error When Trying to Use Npgsql to COPY into a PostgreSQL Database
Date
Msg-id 53A9E819.9020205@aklaver.com
Whole thread Raw
In response to Re: Error When Trying to Use Npgsql to COPY into a PostgreSQL Database  (Altec103 <goldenbabbler@gmail.com>)
List pgsql-general
On 06/24/2014 01:37 PM, Altec103 wrote:
> Adrian, I actually figured it out. It was a really silly mistake - basically
> I was testing something earlier and edited my ODBC connection string. I was
> actually connecting to the wrong database and it was an empty database, so
> ODBCDataReader was trying to pull data from an empty table. Anyways, this is
> fixed. However, I have a new problem.
>
> I occasionally get an ERROR: 22021: invalid byte sequence for encoding
> "UTF8": 0x92 when using the COPY query and this stops the whole process. It
> occurs here in my code...
>
> var raw = Encoding.UTF8.GetBytes(string.Concat(dataEntry, "\n"));
> copy.CopyStream.Write(raw, 0, raw.Length);
>
> dataEntry is a string. I have tried a few things to try and remove any
> non-UTF8 characters from the string, but it has failed so far. Any ideas?

Look at this page:

http://www.postgresql.org/docs/9.3/interactive/multibyte.html

Postgres recognizes and can convert quite a few character sets. If you
know what character set you are working with you can use SET
CLIENT_ENCODING. See bottom of above page for examples.

>
>
>



--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Altec103
Date:
Subject: Re: Error When Trying to Use Npgsql to COPY into a PostgreSQL Database
Next
From: Merlin Moncure
Date:
Subject: Re: JSON Indexes