Re: Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns - Mailing list pgsql-sql

From Mario Splivalo
Subject Re: Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns
Date
Msg-id 49196C31.6010409@megafon.hr
Whole thread Raw
In response to Re: Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns  (Mario Splivalo <mario.splivalo@megafon.hr>)
Responses Postgres version of all_ind_cols
List pgsql-sql
Mario Splivalo wrote:
> But, if I want it other way around, I get the error:
> 
> test1=# select envode(E'\305', 'hex');
> ERROR:  invalid byte sequence for encoding "UTF8": 0xc5
> 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".
> test1=#
> 
> Is there a way to circumvent encoding when dealing with binary data? Or 
> am I completely confused here and have no clue what am I talking about?
> 

Now, this works:

test1=# select encode(decode('C5', 'hex'), 'hex'); encode
-------- c5
(1 row)


I see that my client encoding has a problem interpreting '\xC5':

test1=# select E'\xC5';
ERROR:  invalid byte sequence for encoding "UTF8": 0xc5
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".

So the only way is to use decode function, right?
Mike


pgsql-sql by date:

Previous
From: Mario Splivalo
Date:
Subject: Re: Using UTF strings in pg8.3 - storing hexadecimal values in bytea columns
Next
From: "Bart van Houdt"
Date:
Subject: Postgres version of all_ind_cols