3

In windows how to get the LCID from the std::locale

locale l1(".OCP");//get the default system locale
cout<<l1.c_str()<<endl;

In previous code i get the name of the locale but the win32 LCID this is the required one

ahmedsafan86
  • 1,776
  • 1
  • 26
  • 49
  • The code shown in the questing used a non-conforming extension which I'm trying to [remove](https://github.com/microsoft/STL/pull/3088). Are there any other usages of `std::locale::c_str()`? – F.v.S. Sep 09 '22 at 04:28
  • I don't think so, and upgrade will not be much effort I think. thanks for the update – ahmedsafan86 Sep 19 '22 at 13:36

1 Answers1

1

The only identifying entity associated with a std::locale() is its `name():

std::cout << l1.name() << '\n';

The content of this attribute is rather weakly specified but in the above setup it should have a name and yield something different from "*" which is what is returned for unnamed locales. What the name is, isn't specified, however.

Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380
  • I now that and I asked about the win32 LCID – ahmedsafan86 Sep 01 '13 at 13:52
  • We can use the name to create _locale_t instance and then use the solution in this link, it give a correct LCID but I don't know if it is trusted solution!? http://forums.codeguru.com/showthread.php?513199-Get-LCID-from-CRT-s-_locale_t – ahmedsafan86 Sep 01 '13 at 14:00