Standard C Language Internationalization Programming
Locale

In Internationalization Programming, 'setlocale()' is called to set the current locale to the program at the beginning, typically in 'main()'. The syntax is as follows:
    #include <locale.h>
    char *setlocale(int category, const char *locale)
'setlocale()' sets a locale specified by the second argument to a category specified by the first argument. A category is a set of constant macros defined in locale.h. The following constants are defined:
---------------------------------------------------------------------------
Category	Operations affected by locale
---------------------------------------------------------------------------
LC_COLLATE	Regular expressions matching and string collation
LC_CTYPE	Character operations such as classification and conversion
LC_MESSAES	Natural-language messages
LC_MONETARY     Currency unit and monetary formatting
LC_NUMERIC	Number formatting
LC_TIME		Date and time formatting
LC_ALL		All of the above
---------------------------------------------------------------------------
Usually, the current locale is set to all locale categories by calling 'setlocale()' with 'LC_ALL' and "" (zero-length string).
    setlocale(LC_ALL, "");
You can specify a locale name explicitly, for example "fr_FR.ISO8859-1", but it is not recommended to restrict a locale this way without special reason.

You can get the current locale information with 'setlocale()' by specifying 'NULL' as the second argument.

    char *locale;
	:
    locale = setlocale(LC_CTYPE, NULL);
The following are the standard C library functions related to locale:
-------------------------------------------------------------------------------------
Function	     Description
-------------------------------------------------------------------------------------
setlocale()	     Sets the current locale 
localeconv()         Gets a locale-specific information 
nl_langinfo()*1)     Gets a locale-specific information 
strftime()           Formats the date and time specified 
strptime()           Converts a string representation of time to a time tm structure 
strfmon()            Converts a monetary value to a string
-------------------------------------------------------------------------------------

*1) Arguments 'YESSTR' and 'NOSTR' are deprecated.
   Use 'YESEXPR' and 'NOEXPR' instead.

The following are the mappings of international functions and non-international functions regarding locale:
------------------------------------
Non-international     International
function              function
------------------------------------
asctime()	      strftime()
ctime()		      strftime()
------------------------------------

Go to Internationalization Programming Top


Copyright (C) 2012 Kokusaika JP, Inc.
All rights reserved. No reproduction or republication without written permission.