Re: UTF8 is a better option than US-ASCII for the default encoding of PGStream

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Chang Chao <charleschung(dot)cn(at)gmail(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: UTF8 is a better option than US-ASCII for the default encoding of PGStream
Date: 2015-10-13 12:34:43
Message-ID: CADK3HHLsWYsfOrgkY5=--sn2+scCu+qdnSoBjwqNcrSjrFA3Zw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Chang,

Seems reasonable to me. US-ASCII is actually a subset so it really won't
change anything for the part of the world that does use US-ASCII

Dave Cramer

davec(at)postgresintl(dot)com
www.postgresintl.com

On 13 October 2015 at 03:42, Chang Chao <charleschung(dot)cn(at)gmail(dot)com> wrote:

> Hi,all
> The 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-8
> see
> 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-8
> see
> 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.
> Charles.
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kohei Nozaki 2015-10-13 13:04:52 Re: AbstractJdbc2ResultSet.FAST_NUMBER_FAILED brings class loader leak
Previous Message Álvaro Hernández Tortosa 2015-10-13 09:18:33 Re: UTF8 is a better option than US-ASCII for the default encoding of PGStream