Jump to content

c localization functions

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Michael Safyan (talk | contribs) at 15:17, 31 July 2008 ( Created page with '{{lowercase}} In computing, '''locale.h''' is an C programming language header file, used for purposes of [[Internationalizati...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In computing, locale.h is an C programming language header file, used for purposes of localization. The header provides two key function: localeconv and setlocale. The former provides access to the current locale, while the latter allows one to set the current locale. The header also defines the struct lconv, which stores information about a given locale, including the local preference for the display of numbers and currency.

Usage

Inclusion

C

#include <locale.h>

C++

#include <clocale>

Functions

struct lconv* localeconv(void);
char* setlocale(int, const char*);

Example

#include <iostream>
#include <cstdlib>
#include <clocale>

int main(int argc, char* argv[])
{
  lconv* currentlocale = localeconv();
  std::cout<<"In the current locale, the default currency symbol is: " << currentlocale->currency_symbol << std::endl;
  return 0;
}

References

  1. locale.h by OpenGroup
  2. localeconv by OpenGroup
  3. setlocale by OpenGroup