On Sun, May 16, 2021 at 6:29 AM Noah Misch <n...@leadboat.com> wrote:

> On Mon, Apr 19, 2021 at 05:42:51PM +1200, Thomas Munro wrote:
>
> > The question we asked ourselves
> > multiple times in the other thread was how we're supposed to get to
> > the modern BCP 47 form when creating the template databases.  It looks
> > like one possibility, since Vista, is to call
> > GetUserDefaultLocaleName()[2]
>
> > No patch, but I wondered if any Windows hackers have any feedback on
> > relative sanity of trying to fix all these problems this way.
>
> Sounds reasonable.  If PostgreSQL v15 would otherwise run on Windows Server
> 2003 R2, this is a good time to let that support end.
>
> The value returned by GetUserDefaultLocaleName() is a system configured
parameter, independent of what you set with setlocale(). It might be
reasonable for initdb but not for a backend in most cases.

You can get the locale POSIX-ish name using GetLocaleInfoEx(), but this is
no longer recommended, because using LCIDs is no longer recommended [1].
Although, this would work for legacy locales. Please find attached a POC
patch showing this approach.

[1] https://docs.microsoft.com/en-us/globalization/locale/locale-names

Regards,

Juan José Santamaría Flecha

Attachment: 0001-POC-Make-Windows-locale-POSIX-looking.patch
Description: Binary data

Reply via email to