Re: postgres.app OS X psql character encoding (utf-8) problem - Mailing list pgsql-general

From Tom Lane
Subject Re: postgres.app OS X psql character encoding (utf-8) problem
Date
Msg-id 17842.1389301751@sss.pgh.pa.us
Whole thread Raw
In response to postgres.app OS X psql character encoding (utf-8) problem  (Chris Hiestand <chiestand@salk.edu>)
Responses Re: postgres.app OS X psql character encoding (utf-8) problem  (Chris Hiestand <chiestand@salk.edu>)
List pgsql-general
Chris Hiestand <chiestand@salk.edu> writes:
> If I enter a unicode character in the psql cli, such as:
> user=# select '�';

> But before hitting enter, use the keyboard "left" button to move the cursor across all the way to the left edge, and
thenback all the way to the right, the output get distorted and looks like this: 
> user=#select '�';;

What this sounds like is that the readline or libedit library doesn't
understand multibyte characters properly.  psql itself doesn't have
anything to do with the display of un-entered lines, but relies on
one of those libraries to manage input editing.

The default situation on OS X is generally that psql gets linked against
the Apple-supplied libedit, which goes so far as to masquerade as
readline.  Check "otool -L /path/to/psql"; if you see a reference to
/usr/lib/libedit.3.dylib, or to /usr/lib/libreadline.dylib
(which is really just a symlink to the former), then that's what you've
got.  While I'm generally a fan and user of Apple stuff, their version
of libedit is just abysmal; we've seen random crashes, complete failure
of tab completion, and other bugs in successive OS X releases.  I also
find specific references to multibyte input being busted in other
distros' versions of libedit, eg
http://www.postgresql.org/message-id/4D5B2C5A.8090506@catalyst.net.nz
so it may not be all Apple's fault; but they definitely have a track
record of shipping broken versions of libedit.

I'd strongly recommend installing the GNU readline library and rebuilding
psql against that.

            regards, tom lane


pgsql-general by date:

Previous
From: Chris Hiestand
Date:
Subject: postgres.app OS X psql character encoding (utf-8) problem
Next
From: David Johnston
Date:
Subject: Re: Add custom properties to a column's definition (pg_attribute)