From: Noah Misch <noah@leadboat.com>
To: 阎兆珣 <yanzhaoxun@greendh.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: language code incompatibility in Windows
Date: Tue, 11 Oct 2016 06:42:18 +0000
Message-ID: <20161011064218.GA1041260@tornado.leadboat.com> (raw)
In-Reply-To: <464164567.47460.1473217348129.JavaMail.root@wmthree-8>
References: <464164567.47460.1473217348129.JavaMail.root@wmthree-8>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Wed, Sep 07, 2016 at 11:02:28AM +0800, 阎兆珣 wrote:
> For PG 9.1 ~ 9.5 in Windows 7 32bit
>
> psql can not recognize Chinese database name while pgAdmin III can.
>
> psql_Chinese
This is probably a symptom of a character encoding mismatch. You ran psql in
a console window, so psql received your input encoded with the console input
code page. Based on [1], pgAdmin III probably used UTF8 encoding in your
environment. The default console input code page depends on locale settings,
but it is never UTF8.
This C program demonstrates psql's ability to connect to a Chinese-named
database on Windows (tested with binaries from [2]):
/* initdb --locale=C --encoding=UTF8 */
#include <stdlib.h>
int main(int argc, char **argv)
{
system("createdb \xe5\xa3\xa4");
system("psql -c "
"\"select current_database(), octet_length(current_database())\" "
"\xe5\xa3\xa4");
return 0;
}
I recommend against non-ASCII characters in database names. PostgreSQL
performs encoding conversion, according to the client_encoding setting, on
most of the database session. It does not convert database names; it largely
treats them as byte sequences, not text. Non-ASCII database names work fine
if every client program uses the same encoding; otherwise, they create the
trouble you're experiencing. Avoid non-ASCII role names, too, for the same
reasons.
[1] https://www.postgresql.org/message-id/CA%2BOCxozjhM5wAj84vjRNWX5TLEYEMYeh37U%3DibJt22m5nqtJmA@mail.g...
[2] http://get.enterprisedb.com/postgresql/postgresql-9.5.4-2-windows-x64-binaries.zip
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: noah@leadboat.com, yanzhaoxun@greendh.com
Subject: Re: language code incompatibility in Windows
In-Reply-To: <20161011064218.GA1041260@tornado.leadboat.com>
References: <464164567.47460.1473217348129.JavaMail.root@wmthree-8> <20161011064218.GA1041260@tornado.leadboat.com>
* 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