Name

wsetlocale
- sets the current locale

Library

libc.lib

Synopsis

  #include <wchar.h>
  wchar_t * wsetlocale (int category, const wchar_t *locale);

Return values

Upon successful completion, wsetlocale returns the wide char string associated with the specified category for the requested locale. The wsetlocale function returns NULL and fails to change the locale if the given combination of category and locale make no sense.

Detailed description

The wsetlocale function sets the C library’s notion of natural language formatting style for particular sets of routines. Each such style is called a 'locale' and is invoked using an appropriate name passed as a wide char string.

The wsetlocale function can recognise several categories of routines. The categories and the sets of routines recognised by wsetlocale are listed below:

LC_ALL Set the entire locale generically.
LC_COLLATE Set a locale for string collation routines. Currently locale setting does not have effect on this category.
LC_CTYPE This controls recognition of upper and lower case, alphabetic or non-alphabetic characters, and so on. Currently locale setting does not have effect on this category.
LC_MESSAGES
  Set a locale for message catalogs. Currently this category is not supported.
LC_MONETARY
  Set a locale for formatting monetary values; this affects the localeconv function.
LC_NUMERIC Set a locale for formatting numbers. This controls the formatting of decimal points in input and output of floating point numbers in functions such as printf and scanf, as well as values returned by localeconv.
LC_TIME Set a locale for formatting dates and times using the strftime function.

Only three locales are defined by default, the empty string which denotes the native environment, the C and the POSIX locales, which denote the C language environment. A locale argument of NULL causes wsetlocale to return the current locale. By default, C programs start in the C locale. The only functions in the library that set the locale are wsetlocale and setlocale; the locale is never changed as a side effect of some other routine.


Examples

#include<stdio.h>
#include<wchar.h>
int main()
{
        //Set the locale to UK English
        wchar_t* locale = wsetlocale(LC_ALL,L"en_GB.ISO-8859-1");
        //Check whether locale setting is succesful or not
        if(NULL != locale)
        {
                wprintf(L"Locale setting is successful\n");
                wprintf(L"Locale is set to %s\n", locale);
        }
        else
        {
                wprintf(L"Locale setting failed\n");
        }
        return 0;
}

         

Output

Locale setting is successful
Locale is set to en_GB.ISO-8859-1

         

Errors

No errors are defined.

See also

setlocale, localeconv, nl_langinfo


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top