Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > std::locale cto...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 44201 of 47448
Post > Topic >>

std::locale ctor fails (L10n with C++)

by Sashi Asokarajan <sashi@[EMAIL PROTECTED] > Mar 29, 2008 at 06:21 PM

Hello,

recently I stepped over Strotrup's TC++PL (third ed.) Chapter D.1
where the localization sup****t 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?

Sa****
 




 6 Posts in Topic:
std::locale ctor fails (L10n with C++)
Sashi Asokarajan <sash  2008-03-29 18:21:00 
Re: std::locale ctor fails (L10n with C++)
=?UTF-8?B?RXJpayBXaWtzdHL  2008-03-29 18:05:32 
Re: std::locale ctor fails (L10n with C++)
"Maarten Kronenburg&  2008-03-29 19:39:48 
Re: std::locale ctor fails (L10n with C++)
Sashi Asokarajan <sash  2008-03-29 22:40:56 
Re: std::locale ctor fails (L10n with C++)
James Kanze <james.kan  2008-03-30 03:14:34 
Re: std::locale ctor fails (L10n with C++)
Sashi Asokarajan <sash  2008-03-30 13:55:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 27 17:46:00 CDT 2008.