---
name: "newlocale"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["linux", "freebsd", "macos"]
url: "https://new.carta.tech/newlocale"
---

# newlocale(3)

Create a new locale

## NAME

**newlocale** – Create a new locale

## SYNOPSIS

**#include \<xlocale.h\>**

*locale\_t*\

**newlocale**(*int mask*, *const char \* locale*, *locale\_t base*);

## DESCRIPTION

Creates a new *locale\_t* based off the locale specified by *base*. The categories specified by *mask* will be replaced to correspond with the named *locale*.

The *mask* is the logical OR of the following:

- LC\_COLLATE\_MASK

  Collation

- LC\_CTYPE\_MASK

  Character type

- LC\_MESSAGES\_MASK

  Messages

- LC\_MONETARY\_MASK

  Monetary

- LC\_NUMERIC\_MASK

  Numeric

- LC\_TIME\_MASK

  Time

- LC\_ALL\_MASK

  The logical OR of all of the above

The *locale* string is typically the name of one of the directories in */usr/share/locale*. If *locale* is NULL, then the C locale is used. If *locale* is an empty string, then it will look for environment variables: LC\_ALL, then LC\_\* if the corresponding LC\_\*\_MASK bit is set, then the LANG environment variable. If none of these are found, it will default to the C locale.

If *base* is NULL, the current locale is used. If *base* is LC\_GLOBAL\_LOCALE, the global locale is used.

If *mask* is LC\_ALL\_MASK, *base* is ignored. In order to create a C *locale\_t* value, use **newlocale**(*LC\_ALL\_MASK*, *NULL*, *NULL*).

## RETURN VALUES

Returns a new *locale\_t*, or NULL in case of error. New locales should be freed with [freelocale(3)](/freelocale/3.md).

## SEE ALSO

[duplocale(3)](/duplocale/3.md), [freelocale(3)](/freelocale/3.md), [querylocale(3)](/querylocale/3.md), [uselocale(3)](/uselocale/3.md), [xlocale(3)](/xlocale/3.md)
