OpenBSD manual page server

Manual Page Search Parameters

NEWLOCALE(3) Library Functions Manual NEWLOCALE(3)

newlocale, duplocale, freelocalecreate and destroy locale objects

#include <locale.h>

locale_t
newlocale(int mask, const char *locname, locale_t oldloc);

locale_t
duplocale(locale_t oldloc);

void
freelocale(locale_t oldloc);

The function () creates a new locale object for use with uselocale(3) and with many functions that accept locale_t arguments.

On OpenBSD, mask is only meaningful if it includes LC_CTYPE_MASK, and locname is only meaningful if it is "C" or "POSIX", if it ends with ".UTF-8", or if it is an empty string; otherwise, () always returns the C locale.

On OpenBSD, () ignores oldloc, and passing (locale_t)0 is recommended.

The function () copies oldloc, or the global locale if given the special argument LC_GLOBAL_LOCALE.

For portability, when an object returned from () or duplocale() is no longer needed, pass it to (), even though the latter has no effect on OpenBSD. The oldloc objects passed to newlocale() or freelocale() become invalid, and using them or passing them once again to freelocale() results in undefined behaviour, whereas objects passed to duplocale() remain valid and can be passed to freelocale() later on.

The functions newlocale() and duplocale() return the new locale object on success or (locale_t)0 on failure.

If locname is an empty string, newlocale inspects LC_ALL, LC_CTYPE, and LANG as described in locale(1).

The function newlocale() fails if:

[]
An invalid bit is set in mask, or locname is NULL.
[]
Locale data is not available for locname.

On other operating systems, newlocale() and duplocale() may also fail with ENOMEM.

iswalnum(3), iswctype(3), towctrans(3), towlower(3), uselocale(3), wcscasecmp(3), wctrans(3), wctype(3)

These functions conform to IEEE Std 1003.1-2008 (“POSIX.1”).

These functions have been available since OpenBSD 6.2.

September 5, 2017 OpenBSD-6.3