Re: PostgreSQL Windows Installer defaults to "English_United States.1252" when choosing locale starting with "English" - Mailing list pgsql-bugs

From Thomas Munro
Subject Re: PostgreSQL Windows Installer defaults to "English_United States.1252" when choosing locale starting with "English"
Date
Msg-id CA+hUKGKcfWRyr2nJTmUtL-hN2bHD4-JU-gooxqGGKdyu4hbk_g@mail.gmail.com
Whole thread Raw
In response to Re: PostgreSQL Windows Installer defaults to "English_United States.1252" when choosing locale starting with "English"  (Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>)
List pgsql-bugs
On Thu, Jul 10, 2025 at 12:41 AM Sandeep Thakkar
<sandeep.thakkar@enterprisedb.com> wrote:
> Yes, you are correct. I got the same result. But it was correct when I chose the BCP-47 name like en-uk. Probably
somethingto do with how initdb is handling the long names. 

What's the exact initdb command in this case?  I'm a bit confused
about ""English, United Kingdom" vs "English_United Kingdom.1252".  I
think maybe the Windows C library is doing this, because that first
form isn't really a supported form, and it only manages to grok the
first word with some best-match scheme?  I don't have Windows but I
just pushed a stupid test program to CI to test that theory:

#include <locale.h>
#include <stdio.h>
#include <stdlib.h>

const char *or_null(const char *s)
{
    return s == NULL ? "<null>" : s;
}

int
main(int argc, char *argv[])
{
    if (setlocale(LC_ALL, "English, United Kingdom") == NULL)
        printf("error 1\n");
    printf("got: %s\n", or_null(setlocale(LC_ALL, NULL)));
    if (setlocale(LC_ALL, "English_United Kingdom") == NULL)
        printf("error 2\n");
    printf("got: %s\n", or_null(setlocale(LC_ALL, NULL)));
    if (setlocale(LC_ALL, "English_United Kingdom.1252") == NULL)
        printf("error 3\n");
    printf("got: %s\n", or_null(setlocale(LC_ALL, NULL)));
    return EXIT_SUCCESS;
}

And lo and behold it printed:

got: English_United States.1252
got: English_United Kingdom.1252
got: English_United Kingdom.1252

Apparently it really needs that underscore.



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18983: Problems with Postgres "make check" under ASAN
Next
From: Amit Kapila
Date:
Subject: Re: Unexpected behavior when setting "idle_replication_slot_timeout"