Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 581FB63222C for ; Wed, 7 Jan 2009 12:37:33 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 58529-07 for ; Wed, 7 Jan 2009 12:37:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id 687E9631A2D for ; Wed, 7 Jan 2009 12:37:29 -0400 (AST) Received: (qmail 1606 invoked by uid 512); 7 Jan 2009 16:37:26 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 7 Jan 2009 16:37:26 -0000 Received: from unknown (HELO ?192.168.11.3?) (219.61.40.6) by sd.tpf.co.jp with SMTP; 7 Jan 2009 16:37:26 -0000 Message-ID: <4964DA42.9040401@tpf.co.jp> Date: Thu, 08 Jan 2009 01:37:22 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: ITAGAKI Takahiro CC: Hiroshi Saito , pgsql-hackers Subject: Re: Solve a problem of LC_TIME of windows. References: <20081126174021.EFC6.52131E4D@oss.ntt.co.jp> <492D1707.3060403@tpf.co.jp> <20090107140111.810A.52131E4D@oss.ntt.co.jp> In-Reply-To: <20090107140111.810A.52131E4D@oss.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.125 tagged_above=0 required=5 tests=DNS_FROM_RFC_BOGUSMX=2.125 X-Spam-Level: ** X-Archive-Number: 200901/478 X-Sequence-Number: 131122 ITAGAKI Takahiro wrote: > Hiroshi Inoue wrote: > >> Seems LC_CTYPE and LC_TIME should be convertible even though we use >> wcsftime (which internally calls strftime?). > > Ok, wcsftime() requries both LC_TIME and LC_CTYPE are the same setting > (at least encoding) on Windows. > > The attached patch is an updated version to fix cache_locale_time(). > Now it sets LC_TIME and LC_CTYPE to the specified locale and restore > them at end of the function. I tested the patch on Windows XP Japanese > Edition (SJIS) with UTF-8 and EUCJP databases, and worked expectedly. I've also thought a similar implementation but there seems a problem of efficiency. As far as I see wcsftime() is almost = strftime() + mbstowcs() and so using strftime() is effective at least for the following cases. 1) LC_CTIME is "C". 2) LC_CTYPE != C and the database encoding != UTF-8. In this case the current restriction of PostgreSQL requires that the database encoding matches the encoding of the LC_CTYPE. We seem to be able to call strftime() directly in above cases. Comments ? regards, Hiroshi Inoue