Internationalization and localization tools


Locale-Sensitive Function

char *setlocale(int category, const char *locale);

wchar_t *_wsetlocale(int category, const wchar_t *locale);

TCHAR *_tsetlocale(int category, const TCHAR *locale);

Internationalization (I18n) Function Overview

The setlocale function sets the current locale for category to locale. If the category is LC_ALL, then the specified locale will be set for all categories. If a valid locale and category are given, the function returns a string that is the name of the locale currently selected for the specified category; a null pointer is returned in the event of an error.

If NULL is passed for the locale argument, then the function returns the name of the locale for the specified category.

_wsetlocale is supported only on Windows platforms, and is the wide-character version of setlocale; its argument and return are wide-character strings.

_tsetlocale is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either setlocale or _wsetlocale.

I18n Issues

Use the appropriate version of the function as required for internationalization support, noting the following:

On ANSI platforms, there is no wide character version of setlocale. Instead, use a conversion routine to convert the wide character locale string to a multibyte character string and call setlocale.

For general information on locales, refer to the Locales in C++ topic.

Recommended Function Replacements

Locale-Sensitive Functions

 

Lingoport internationalization and localization services and software