2

How can I check, which value should I pass to std::locale? I wrote simple program:

#include <cstdio>
#include <locale>
#include <stdexcept>

int main()
{
   try
   {
      std::locale("plk_pol");
   }
   catch(std::runtime_error)
   {
      printf("Can't load locale.\n");
      return 1;
   }

   return 0;
}

But it gives me error message. That's strange, because std::setlocale(LC_ALL, 'plk_pol'); works. I tried other values, like pl_PL, polish_poland - behaviour is the same. Even en_US.utf8 gives error. The only locale I was able to set is C.

I have Windows 7 with Polish localisation set. The question is: where can I check, which locales are acceptable in my system?

Devolus
  • 21,661
  • 13
  • 66
  • 113
user132443
  • 55
  • 4
  • I know it works for some people, because I based my code on ideas from google. But it doesn't work for ME, and I want to know why and how to repair it... – user132443 Mar 22 '14 at 11:43
  • I think this link might be interesting for you, although it does not answer your question: http://stackoverflow.com/questions/4406895/what-stdlocale-names-are-available-on-common-windows-compilers – Alexander Tobias Bockstaller Mar 22 '14 at 11:58
  • You're wrong, it answered my question. "MinGW C++ std::locale accepts "C" and "POSIX" it does not support other locales, actually gcc supports locales only over GNU C library - basically only under Linux. setlocale is native Windows API call so should support all I mentioned above." I use MinGW, but I didn't think it's important. This piece of shit... Any news, when it will work in MinGW? Anyway, please post your comment (or that what I just cited) as answer and I'll accept it. – user132443 Mar 22 '14 at 13:37

0 Answers0