How to paste chinese characters in psql terminal? I am trying to paste chinese characters into psql terminal:

$ psql
=&gt; \encoding
=&gt; UTF8
# Ctrl+v (艺术与设计)
=&gt; ?????设计


When pasting into normal terminal (Max OS) it works fine:

$ # Ctrl+v (艺术与设计)
$ 艺术与设计


What might be wrong?
psql delegates the handling of input to a shared library, which is either libreadline or libedit.

But libedit used to not work reliably with multibyte character sets, as has been reported on multiple occasions, here for OSX for example.

From your comment:


  /Library/PostgreSQL/9.4/bin/psql -&gt; libedit@1.47.0 does not work, /Library/PostgreSQL/9.4/bin/psql -&gt; libedit@1.48.0 does not work BUT /Applications/Postgres.app/Contents/Versions/9.4/bin/psql -&gt; libedit@3.0.0 works!


...it seems that by relinking to a newer version, you were able to solve the problem. That's useful to know.

The reason why libedit is used at all while libreadline did a better job first is that the latter is licensed under the GPL, whereas psql is BSD-licensed like the rest of PostgreSQL. A consequence is that psql cannot be shipped in compiled form with the necessary parts that call libreadline, without breaching its license. On the other hand libedit uses the BSD license, so it's OK to ship with it.

The solution for psql packagers so far has been to ship PostgreSQL with libedit and let the users relink it with libreadline if necessary.

On Linux, the Debian/Ubuntu packages even do this dynamically without the user intervening.