Re: Can we get rid of GetLocaleInfoEx() yet?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Can we get rid of GetLocaleInfoEx() yet?
Date: 2020-03-29 17:00:23
Message-ID: 28339.1585501223@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?UTF-8?Q?Juan_Jos=C3=A9_Santamar=C3=ADa_Flecha?= <juanjo(dot)santamaria(at)gmail(dot)com> writes:
> On Sun, Mar 29, 2020 at 3:29 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> The reason for the hack, per the comments, is that VS2015
>> omits a codepage field from the result of _create_locale();
>> and some optimism is expressed therein that Microsoft might
>> undo that oversight in future. Has this been fixed in more
>> recent VS versions? If not, can we find another, more robust
>> way to do it?

> While working on another issue I have seen this issue reproduce in VS2019.
> So no, it has not been fixed.

Oh well, I figured that was too optimistic :-(

> Please find attached a patch that provides a better detection of the "uft8"
> cases.

In general, I think the problem is that we might be dealing with a
Unix-style locale string, in which the encoding name might be quite
a few other things besides "utf8". But actually your patch works
for that too, since what's going to happen next is we'll search the
encoding_match_list[] for a match. I do suggest being a bit more
paranoid about what's a codepage number though, as attached.
(Untested, since I lack a Windows environment, but it's pretty
straightforward code.)

regards, tom lane

Attachment Content-Type Size
fix_win32_langinfo-2.patch text/x-diff 1.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Juan José Santamaría Flecha 2020-03-29 17:06:56 Re: Can we get rid of GetLocaleInfoEx() yet?
Previous Message Tom Lane 2020-03-29 16:37:05 Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction