• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with std::locale
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Problem with std::locale
      • From: Chris Espinosa <email@hidden>
    • Re: Problem with std::locale
      • From: "Jim Crafton" <email@hidden>
    • Re: Problem with std::locale
      • From: Steve Checkoway <email@hidden>
  • Prev by Date: Xcode 3.0 + Subversion + Large'ish Repository = Very Slow Revision History
  • Next by Date: CVS and Warning: No xauth data...
  • Previous by thread: Re: Xcode 3.0 + Subversion + Large'ish Repository = Very Slow Revision History
  • Next by thread: Re: Problem with std::locale
  • Index(es):
    • Date
    • Thread