1.Dd March 11, 2005
2.Dt NEWLOCALE 3
3.Os
4.Sh NAME
5.Nm newlocale
6.Nd Create a new locale
7.Sh SYNOPSIS
8.In xlocale.h
9.Ft locale_t
10.Fn newlocale "int mask" "const char * locale" "locale_t base"
11.Sh DESCRIPTION
12Creates a new
13.Vt locale_t
14based off the locale specified by
15.Va base .
16The categories specified by
17.Va mask
18will be replaced to correspond with the named
19.Va locale .
20.Pp
21The
22.Va mask
23is the logical OR of the following:
24.Bl -tag -width LC_MONETARY_MASK
25.It Dv LC_COLLATE_MASK
26Collation
27.It Dv LC_CTYPE_MASK
28Character type
29.It Dv LC_MESSAGES_MASK
30Messages
31.It Dv LC_MONETARY_MASK
32Monetary
33.It Dv LC_NUMERIC_MASK
34Numeric
35.It Dv LC_TIME_MASK
36Time
37.It Dv LC_ALL_MASK
38The logical OR of all of the above
39.El
40.Pp
41The
42.Va locale
43string is typically the name of one of the directories in
44.Pa /usr/share/locale .
45If
46.Va locale
47is
48.Dv NULL ,
49then the C locale is used. If
50.Va locale
51is an empty string, then it will look for environment variables:
52LC_ALL, then LC_* if the corresponding LC_*_MASK bit is set, then
53the LANG environment variable. If none of these are found, it
54will default to the C locale.
55.Pp
56If
57.Va base
58is
59.Dv NULL ,
60the current locale is used. If
61.Va base
62is
63.Dv LC_GLOBAL_LOCALE ,
64the global locale is used.
65.Pp
66If
67.Va mask
68is
69.Dv LC_ALL_MASK ,
70.Va base
71is ignored. In order to create a C
72.Vt locale_t
73value, use
74.Fn newlocale "LC_ALL_MASK" "NULL" "NULL" .
75.Sh RETURN VALUES
76Returns a new
77.Vt locale_t ,
78or
79.Dv NULL
80in case of error.
81New locales should be freed with
82.Xr freelocale 3 .
83.Sh SEE ALSO
84.Xr duplocale 3 ,
85.Xr freelocale 3 ,
86.Xr querylocale 3 ,
87.Xr uselocale 3 ,
88.Xr xlocale 3
89