newlocale -- allocate a locale object


#include <locale.h>

locale_t newlocale(int category_mask, const char * locale, locale_t base);


The newlocale() function shall initialize a locale object. If base is NULL, then newlocale() shall first allocate the object; otherwise it shall use the locale object referenced by base.

The object shall be initialized for the locale named by locale, and for the categories selected in category_mask. The category_mask value is a bitwise inclusive OR of the required LC_name_MASK values, or the value LC_ALL_MASK.

Return Value

On success, the newlocale() function shall return the initialized locale object. Otherwise, it shall return NULL, and set errno to indicate the error.


The newlocale() function shall fail if:


Insufficient memory.


An invalid category_mask was provided, or the locale was NULL.


For any of the categories in category_mask, the locale data is not available.

Application Usage (Informative)

The only portable way to allocate a locale object is to call newlocale() with a NULL base. The allocated object may be reinitialized to a new locale by passing it back to newlocale(). The new object may be released by calling freelocale().

See Also

setlocale(), freelocale(), duplocale(), uselocale()