Re: Problem with std::locale
Re: Problem with std::locale
- Subject: Re: Problem with std::locale
- From: "Jim Crafton" <email@hidden>
- Date: Tue, 22 Apr 2008 13:52:29 -0400
I found when I tried this stuff several years ago that most of it did
not work like I expected and I eventually gave up on it. Instead I
just used the OS X Carbon routines for locale stuff. Good luck.
On Mon, Apr 21, 2008 at 4:34 PM, Dave Carrigan <email@hidden> wrote:
> The following code is not giving expected results. I would expect that any
> locale that can be set using setlocale() could be set by instantiating a
> locale, but in fact, the only locales that I can instantiate are C and
> POSIX.
>
> Any insights?
>
> ------------------------------------------------------------
> #include <locale>
> #include <iostream>
> #include <stdexcept>
>
> using namespace std;
>
> int main(int argc, char *argv[])
> {
> char const* loc = argv[1];
>
> if (std::setlocale(LC_ALL, loc)) {
> cout << loc << ": good C locale; ";
> } else {
> cout << loc << ": bad C locale; ";
> }
>
> try {
> locale l(loc);
> cout << "good C++ locale" << endl;
> } catch (runtime_error& e) {
> cout << "bad C++ locale (" << e.what() << ")" << endl;
> }
>
> return 0;
> }
> ------------------------------------------------------------
>
> $ g++ -o loctst loctst.cc
> $ for loc in C POSIX en_US; do ./loctst $loc; done
> C: good C locale; good C++ locale
> POSIX: good C locale; good C++ locale
> en_US: good C locale; bad C++ locale (locale::facet::_S_create_c_locale
> name not valid)
>
>
> --
> Dave Carrigan
> email@hidden
> Seattle, WA, USA
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden