pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Volker Paul <volker.paul@v-paul.de>
To: pgsql-bugs@postgresql.org
Subject: Re: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
Date: Wed, 9 Mar 2016 20:28:49 -0500
Message-ID: <56E0CDD1.3040708@gmx.net> (raw)
In-Reply-To: <569D27E5.90400@v-paul.de>
References: <569D27E5.90400@v-paul.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 1/18/16 12:59 PM, Volker Paul wrote:
> the following plpythonu function reveals wrong length calculation
> and error on accessing single characters in a Unicode string.

The problem is that in Python 2, source text must be ASCII.  So you need
to escape any non-ASCII characters using \x or \u escapes or something else.

I've tried patching PL/Python so that it automatically inserts a
"coding" declaration per PEP-263, but I haven't gotten that to work yet.

Your example works fine with Python 3, which expects UTF-8 source
encoding, so maybe that's an option for you.  (Although now that I think
about it, that might have failure scenarios in other database encodings.)



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <56E0CDD1.3040708@gmx.net>
Permalink:  ../56E0CDD1.3040708@gmx.net/
Also on:    postgresql.org/message-id/56E0CDD1.3040708@gmx.net

 · 

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: peter_e@gmx.net, volker.paul@v-paul.de
  Subject: Re: Error and wrong lenghth of non-ASCII Unicode string in plpythonu
  In-Reply-To: <56E0CDD1.3040708@gmx.net>
  References: <569D27E5.90400@v-paul.de> <56E0CDD1.3040708@gmx.net>

* 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