Problem with std::locale
Problem with std::locale
- Subject: Problem with std::locale
- From: Dave Carrigan <email@hidden>
- Date: Mon, 21 Apr 2008 13:34:13 -0700
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
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
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