Re: UTF-8 for bytea

From: Marko Kreen <markokr(at)gmail(dot)com>
To: Robert James <srobertjames(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: UTF-8 for bytea
Date: 2011-11-03 09:55:06
Message-ID: CACMqXCKSzpxjL00v5G-j1r6vkNRnfsCm+ZdemaWjWRX=_wSzmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 3, 2011 at 4:34 AM, Robert James <srobertjames(at)gmail(dot)com> wrote:
> When trying to INSERT on Postgres (9.1) to a bytea column, via E''
> escaped strings, I get the strings rejected because they're not UTF8.
> I'm confused, since bytea isn't for strings but for binary.  What
> causes this? How do I fix this? (I know that escaped strings is not
> the best way for binary data, but this is what I'm stuck with for now
> - it's a legacy system which I need to maintain.)

Because the query needs to be utf8. So you need to escape
any non-ascii chars in it. Also keep in mind that bytea is double-quoted.
See the docs for details.

--
marko

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2011-11-03 10:06:49 Re: Why is there no 8.3.16 rpm with _id ?
Previous Message Allan Kamau 2011-11-03 09:15:59 Re: Recommendations for SSDs in production?