Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a way to list all supported locales either the C- or C++-runtime?

40 views
Skip to first unread message

Bonita Montero

unread,
Nov 20, 2020, 10:12:36 AM11/20/20
to
I'm curious about the supported locales of my C- and C++-runtime.
So is there a way to list the supported locales for either the C-
or C++-runtime ?
And if there isn't: are there platform-dependent ways that map 1:1
to the C- or C++-runtime locale-strings for either Linux or Win32 ?
With Windows there's EnumSystemLocalesEx etc., but this doesn't
include the encodings in the locale-strings (i.e. "xxx.UTF" etc.).

Scott Lurndal

unread,
Nov 20, 2020, 11:09:22 AM11/20/20
to
Bonita Montero <Bonita....@gmail.com> writes:
>I'm curious about the supported locales of my C- and C++-runtime.
>So is there a way to list the supported locales for either the C-
>or C++-runtime ?

On linux:

$ ls /usr/share/i18n/locales/
$ ls /usr/share/i18n/locales/ |wc -l
312

James Kuyper

unread,
Nov 20, 2020, 11:45:38 AM11/20/20
to
Or just type "locale -a"

Keith Thompson

unread,
Nov 20, 2020, 2:36:10 PM11/20/20
to
On my system, "locale -a" shows 29 locales, but there are 361 entries in
/usr/share/i18n/locales/. I think some of the files in that directory
don't correspond to locales, but not enough of them to explain the
difference.

--
Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Bonita Montero

unread,
Nov 20, 2020, 2:42:27 PM11/20/20
to
> $ ls /usr/share/i18n/locales/
> $ ls /usr/share/i18n/locales/ |wc -l
> 312

I wan't to have a direct API-call. Of course I could enumerate
the files with opendir() / readdir(), but this isn't really handy.

Jorgen Grahn

unread,
Nov 20, 2020, 2:57:14 PM11/20/20
to
On Fri, 2020-11-20, Keith Thompson wrote:
> James Kuyper <james...@alumni.caltech.edu> writes:
>> On 11/20/20 11:08 AM, Scott Lurndal wrote:
>>> Bonita Montero <Bonita....@gmail.com> writes:
>>>> I'm curious about the supported locales of my C- and C++-runtime.
>>>> So is there a way to list the supported locales for either the C-
>>>> or C++-runtime ?
>>>
>>> On linux:
>>>
>>> $ ls /usr/share/i18n/locales/
>>> $ ls /usr/share/i18n/locales/ |wc -l
>>> 312
>>
>> Or just type "locale -a"
>
> On my system, "locale -a" shows 29 locales, but there are 361 entries in
> /usr/share/i18n/locales/. I think some of the files in that directory
> don't correspond to locales, but not enough of them to explain the
> difference.

Some systems (e.g. Debian) distinguishes between locales which are
theoretically available, and those the sysadmin has choosen to
"generate", i.e. make ready for use. Not generating all of them saves
disk space.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

James Kuyper

unread,
Nov 20, 2020, 2:58:24 PM11/20/20
to
On 11/20/20 2:35 PM, Keith Thompson wrote:
> James Kuyper <james...@alumni.caltech.edu> writes:
>> On 11/20/20 11:08 AM, Scott Lurndal wrote:
>>> Bonita Montero <Bonita....@gmail.com> writes:
>>>> I'm curious about the supported locales of my C- and C++-runtime.
>>>> So is there a way to list the supported locales for either the C-
>>>> or C++-runtime ?
>>>
>>> On linux:
>>>
>>> $ ls /usr/share/i18n/locales/
>>> $ ls /usr/share/i18n/locales/ |wc -l
>>> 312
>>
>> Or just type "locale -a"
>
> On my system, "locale -a" shows 29 locales, but there are 361 entries in
> /usr/share/i18n/locales/. I think some of the files in that directory
> don't correspond to locales, but not enough of them to explain the
> difference.
>

I see the same 361 entries, but locale -a gives 61 locales for me.
Except for the C, C.UTF-8, and POSIX locales, every locale given by
"locale -a" corresponds to one of the 5 languages that I can read, and
for which I've installed fonts. There are, for instance, 22 different
locales for Spanish, which is how the total comes to 61.

Scott Lurndal

unread,
Nov 20, 2020, 2:58:37 PM11/20/20
to
Well, figure it out. The information is all there.

$ man -k locale

https://pubs.opengroup.org/onlinepubs/9699919799/

F Russell

unread,
Nov 20, 2020, 6:22:32 PM11/20/20
to
On Fri, 20 Nov 2020 16:12:11 +0100, Bonita Montero wrote:

>
> So is there a way to list the supported locales for either the C-
> or C++-runtime ?
>

If it is indeed YOUR system then YOU should have set up the locales
that you want:

localedef -c -i en_US -f UTF-8 /usr/lib64/locale/en_US.UTF-8

There are a few built-in or default locales, namely POSIX, C,
and C.utf8, but any others are defined entirely by the user.






--

Systemd free. D.E. free.

Always and forever.

Bonita Montero

unread,
Nov 21, 2020, 6:34:49 AM11/21/20
to
I want an API to list the supproted locales of my implementation.

Scott Lurndal

unread,
Nov 21, 2020, 10:41:42 AM11/21/20
to
Bonita Montero <Bonita....@gmail.com> writes:
>I want an API to list the supproted locales of my implementation.

And I want a million dollars. Neither of us are likely to get our wish
without working for it first.

Manfred

unread,
Nov 21, 2020, 5:07:35 PM11/21/20
to
On one of my systems locale -a gives 867 locales, but there's nothing in
/usr/share/i18n/locales/

On Linux file locations are rather 'fluid'.

Christian Gollwitzer

unread,
Nov 23, 2020, 1:34:38 AM11/23/20
to
Am 21.11.20 um 12:34 schrieb Bonita Montero:
> I want an API to list the supproted locales of my implementation.

If it is "locale -a" as suggested by others, then why not checking the
source code of the locale command to see what this does?

Christian
0 new messages