pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: gpd@gpdnet.co.uk
To: brice@famille-andre.be
To: pgsql-bugs@lists.postgresql.org
Subject: RE: BUG #15261: Insert binary data in bytea rejected due to UTF-8 encoding errors
Date: Wed, 4 Jul 2018 12:13:39 +0100
Message-ID: <349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk> (raw)
In-Reply-To: <153070214603.13259.8727718773496971274@wrigleys.postgresql.org>
References: <153070214603.13259.8727718773496971274@wrigleys.postgresql.org>

> 
> I have a database using UTF-8 encoding and, in which I have bytea columns
> where I store binary data.
> 
> I followed instructions in
> https://www.postgresql.org/docs/9.6/static/datatype-binary.html to encode
> the binary data, but it is still rejected due to a "ERROR:  invalid byte sequence
> for encoding "UTF8"" error.
> 
> I wrote a small script that reproduces the problem in a small database. The
> script can be simply copy-pasted in a psql session:
> 
> CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'UTF8'
> LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8'; \connect test;
> CREATE TABLE test (test bytea); insert into test (test) values
> (E'\xC744'::bytea);
> 

You'll notice in the link you provided for your example that you need an extra backslash ('\') for the escape format you are using.

Regards,
Gary.







view thread (2+ messages)

Message-ID: <349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk>
Permalink:  ../349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk/
Also on:    postgresql.org/message-id/349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: gpd@gpdnet.co.uk, brice@famille-andre.be
  Subject: Re: BUG #15261: Insert binary data in bytea rejected due to UTF-8 encoding errors
  In-Reply-To: <349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk>
  References: <153070214603.13259.8727718773496971274@wrigleys.postgresql.org> <349f01d41388$0f9af300$2ed0d900$@gpdnet.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox