Re: UTF8 is a better option than US-ASCII for the default encoding of PGStream
От | Chang Chao |
---|---|
Тема | Re: UTF8 is a better option than US-ASCII for the default encoding of PGStream |
Дата | |
Msg-id | CAHLX0udhfrGsXtB=G7tHWP1w0neaaeVu=PMvyavTiN89JEmG0Q@mail.gmail.com обсуждение исходный текст |
Ответ на | UTF8 is a better option than US-ASCII for the default encoding of PGStream (Chang Chao <charleschung.cn@gmail.com>) |
Ответы |
Re: UTF8 is a better option than US-ASCII for the default
encoding of PGStream
|
Список | pgsql-jdbc |
After some googling,found that the same issue was already discussed before.
http://postgresql.nabble.com/JDBC-Default-Encoding-td2172427.htmlSo to prevent the error message text garbling,we have to change the value of lc_messages from 'ja_JP.UTF-8' to "en_US.UTF8"?
On Tue, Oct 13, 2015 at 4:48 PM, Chang Chao <charleschung.cn@gmail.com> wrote:
Hi,allThe problem I encountered is that,when lc_messages = 'ja_JP.UTF-8' is set in postgresql.conf,and initial connection to database server failed(for example:user name,password or dbname is misspelled),I see garbled error message text in the client .The reason is that,in PGStream constrcutor,default encoding of ASCII is set(Encoding.getJVMEncoding("US-ASCII")).For the following reasons,maybe UTF8 is a better option for default encoding.1.When initializing connection ,jdbcclient send client_encoding parameter as UTF-8see org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(HostSpec[], String, String, Properties, Logger)2. When initial connection to server completes,jdbc client only receive the value for client_encoding as UTF-8see org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(PGStream, ProtocolConnectionImpl, Logger)if (name.equals("client_encoding")){if (!value.equals("UTF8"))throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION);pgStream.setEncoding(Encoding.getDatabaseEncoding("UTF8"));}So there seems no reason to initiate the encoding as US-ASCII.Best regards.Chao.
В списке pgsql-jdbc по дате отправления: