Re: not valid character for Unicode - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: not valid character for Unicode
Date
Msg-id 20060609152502.GD26418@svana.org
Whole thread Raw
In response to Re: not valid character for Unicode  (Adam Witney <awitney@sgul.ac.uk>)
Responses Re: not valid character for Unicode  (Adam Witney <awitney@sgul.ac.uk>)
List pgsql-general
On Fri, Jun 09, 2006 at 04:17:50PM +0100, Adam Witney wrote:
> > It's a valid unicode character, it's just you havn't encoded it in
> > unicode. It's probably in Latin-1. In that case, you need to specify it
> > in the client encoding...
>
> Hi Martijn,
>
> thanks for your quick response.
>
> Ok i am a bit confused by all this encoding stuff... i don't really know
> how to encode it in unicode? this is a text string that is extracted
> from a text file, i just put it in an INSERT statement.

The database will do the encoding for you, you just have to tell it
what encoding it is. By default it assumes you're using the same
encoding as the backend. So:

# set client_encoding='latin1';

-- Now all my strings are considered to be in latin1

# set client_encoding='sjis';

-- Now my strings are SJIS

# set client_encoding='unicode';

-- Now my strings need to be utf-8

> I have to replace fields with this in it with a valid string that will
> load into 8.1, do you know who i would do the conversion?

The database will do it for you. Note that the client encoding affects
input *and* output. So if you set it to latin1, the database will
convert all strings to latin1 before sending them to you...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Fabian Pascal and RDBMS deficiencies in fully implementing the relational model
Next
From: brian ally
Date:
Subject: Re: not valid character for Unicode