Re: C++ std::locale's ctor only accepts "C" and "POSIX"
Re: C++ std::locale's ctor only accepts "C" and "POSIX"
- Subject: Re: C++ std::locale's ctor only accepts "C" and "POSIX"
- From: Lutz Helwing <email@hidden>
- Date: Mon, 05 May 2008 17:47:26 +0200
I have exactly the same problem and it's a rather fatal one in my case. Am i assuming right that i can't use UTF-8 in my application?
I'm using a part of the boost library. This is most likely the place where the exception is thrown.
It works when i set the default locale of my shell to "C" or "POSIX" but nothing else...
I'm relatively unexperienced in working with locales so i don't have the slightest idea
Since i can't find very much about this exception i wonder if anyone has solved this problem.
I made a small mistake when writing my initial message.
I forgot to print the e.what() message when the std::locale ctor
throws an exception. I've updated the code in the link to do that.
Here's the new output on my OS X machine; as expected, it just says
that the locale name is invalid:
=== BEGING TERMINAL OUTPUT ===
Trying c locales...
Succeeded in calling setlocale(LC_ALL, "C")
Succeeded in calling setlocale(LC_ALL, "POSIX")
Succeeded in calling setlocale(LC_ALL, "en_US")
Succeeded in calling setlocale(LC_ALL, "en_US.UTF-8")
Succeeded in calling setlocale(LC_ALL, "pl_PL")
Succeeded in calling setlocale(LC_ALL, "pl_PL.ISO8859-2")
Trying C++ locales...
Succeeded ctor for std::locale with "C"
Succeeded ctor for std::locale with "POSIX"
Failed ctor for std::locale with "en_US":
locale::facet::_S_create_c_locale name not valid
Failed ctor for std::locale with "en_US.UTF-8":
locale::facet::_S_create_c_locale name not valid
Failed ctor for std::locale with "pl_PL":
locale::facet::_S_create_c_locale name not valid
Failed ctor for std::locale with "pl_PL.ISO8859-2":
locale::facet::_S_create_c_locale name not valid
=== END TERMINAL OUTPUT ===
-Patrick
On Mar 8, 2008, at 9:57 PM, Patrick Rutkowski wrote:
I'm currently studying how locales work in C/C++, I'm using OS X
machine and a Linux machine for testing.
I wrote the following test program to make sure that I can
successfully initialize a few locales on both my systems:
http://www.rutski89.com:31597/upload/test.cpp
Running this on my linux machine I get exactly the output I
expected, all success:
=== BEGING TERMINAL OUTPUT ===
Trying c locales...
Succeeded in calling setlocale(LC_ALL, "C")
Succeeded in calling setlocale(LC_ALL, "POSIX")
Succeeded in calling setlocale(LC_ALL, "en_US")
Succeeded in calling setlocale(LC_ALL, "en_US.UTF-8")
Succeeded in calling setlocale(LC_ALL, "pl_PL")
Succeeded in calling setlocale(LC_ALL, "pl_PL.ISO8859-2")
Trying C++ locales...
Succeeded ctor for std::locale with "C"
Succeeded ctor for std::locale with "POSIX"
Succeeded ctor for std::locale with "en_US"
Succeeded ctor for std::locale with "en_US.UTF-8"
Succeeded ctor for std::locale with "pl_PL"
Succeeded ctor for std::locale with "pl_PL.ISO8859-2"
=== END TERMINAL OUTPUT ===
However, when running on my OS X machine with the stock g++ (running
on 10.5.1) I get the following:
=== BEGING TERMINAL OUTPUT ===
Trying c locales...
Succeeded in calling setlocale(LC_ALL, "C")
Succeeded in calling setlocale(LC_ALL, "POSIX")
Succeeded in calling setlocale(LC_ALL, "en_US")
Succeeded in calling setlocale(LC_ALL, "en_US.UTF-8")
Succeeded in calling setlocale(LC_ALL, "pl_PL")
Succeeded in calling setlocale(LC_ALL, "pl_PL.ISO8859-2")
Trying C++ locales...
Succeeded ctor for std::locale with "C"
Succeeded ctor for std::locale with "POSIX"
Failed ctor for std::locale with "en_US"
Failed ctor for std::locale with "en_US.UTF-8"
Failed ctor for std::locale with "pl_PL"
Failed ctor for std::locale with "pl_PL.ISO8859-2"
=== END TERMINAL OUTPUT ===
It seems that the system is only able to create C++ locales for "C"
and "POSIX", which is puzzling, and also very unsatisfactory.
It would be unhappy, but at least settling, if I found a page that
said something like "C++ locales on OS X only support "C" and
"POSIX", tough luck!". However, such a page is nowhere to be found,
and in fact I have found evidence to the contrary.
Searching "site:apple.com std::locale" in google brings up various
pages where people describe issues with the usage of std::locale.
However, these pages pertain to issues with the usage of the locale
after it has already been created, which implies that the people who
made the posts were actually able to create the locale to begin
with; so why am I not able to create them?
I've been banging my head against the wall for a while now; any help
would be much appreciated
-Patrick
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden