S
Sashi Asokarajan
Hello,
recently I stepped over Strotrup's TC++PL (third ed.) Chapter D.1
where the localization support of the C++ stdlib is explained.
[ http://www.research.att.com/~bs/3rd_loc.pdf ]
Unfortunately the constructor fails if I try to instantiate std::locale
for locales other than C or POSIX.
With (only) LANG="de.DE.UTF-8" set in ENV the following code thows an exception:
std::locale loc("");
and std::setlocale(LC_ALL, ""); works fine?!
My GCC Version is "gcc (GCC) 3.4.6 [FreeBSD] 20060305" and I'm
using FreeBSD 6.2.
Here's my example code:
#include <clocale>
#include <iostream>
int main()
{
using std::cout;
using std::endl;
const char* const lstr = std::setlocale(LC_ALL, "");
if (lstr)
cout << "lstr=" << lstr << endl;
else
cout << "lstr=NULL" << endl;
std::locale loc("");
cout << "std::locale loc=" << loc.name() << endl;
}
Output:
lstr=de_DE.UTF-8
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Abort (core dumped)
Does anyone have similar problems ? What am I doing wrong ?
Is the libstdc++ incomplete on my platform?
Sashi
recently I stepped over Strotrup's TC++PL (third ed.) Chapter D.1
where the localization support of the C++ stdlib is explained.
[ http://www.research.att.com/~bs/3rd_loc.pdf ]
Unfortunately the constructor fails if I try to instantiate std::locale
for locales other than C or POSIX.
With (only) LANG="de.DE.UTF-8" set in ENV the following code thows an exception:
std::locale loc("");
and std::setlocale(LC_ALL, ""); works fine?!
My GCC Version is "gcc (GCC) 3.4.6 [FreeBSD] 20060305" and I'm
using FreeBSD 6.2.
Here's my example code:
#include <clocale>
#include <iostream>
int main()
{
using std::cout;
using std::endl;
const char* const lstr = std::setlocale(LC_ALL, "");
if (lstr)
cout << "lstr=" << lstr << endl;
else
cout << "lstr=NULL" << endl;
std::locale loc("");
cout << "std::locale loc=" << loc.name() << endl;
}
Output:
lstr=de_DE.UTF-8
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
Abort (core dumped)
Does anyone have similar problems ? What am I doing wrong ?
Is the libstdc++ incomplete on my platform?
Sashi