158f0484fSRodney W. Grimes.\" Copyright (c) 1993 258f0484fSRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 358f0484fSRodney W. Grimes.\" 458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 558f0484fSRodney W. Grimes.\" Donn Seeley at BSDI. 658f0484fSRodney W. Grimes.\" 758f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 858f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions 958f0484fSRodney W. Grimes.\" are met: 1058f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 1158f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 1258f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 1358f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 1458f0484fSRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 1558f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 1658f0484fSRodney W. Grimes.\" must display the following acknowledgement: 1758f0484fSRodney W. Grimes.\" This product includes software developed by the University of 1858f0484fSRodney W. Grimes.\" California, Berkeley and its contributors. 1958f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 2058f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 2158f0484fSRodney W. Grimes.\" without specific prior written permission. 2258f0484fSRodney W. Grimes.\" 2358f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2458f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2558f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2658f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2758f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2858f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2958f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3058f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3158f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3258f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3358f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3458f0484fSRodney W. Grimes.\" 3558f0484fSRodney W. Grimes.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 3658f0484fSRodney W. Grimes.\" 3758f0484fSRodney W. Grimes.Dd June 9, 1993 3858f0484fSRodney W. Grimes.Dt SETLOCALE 3 3958f0484fSRodney W. Grimes.Os 4058f0484fSRodney W. Grimes.Sh NAME 4158f0484fSRodney W. Grimes.Nm setlocale , 4258f0484fSRodney W. Grimes.Nm localeconv 4358f0484fSRodney W. Grimes.Nd natural language formatting for C 4458f0484fSRodney W. Grimes.Sh SYNOPSIS 4558f0484fSRodney W. Grimes.Fd #include <locale.h> 4658f0484fSRodney W. Grimes.Ft char * 4758f0484fSRodney W. Grimes.Fn setlocale "int category" "const char *locale" 4858f0484fSRodney W. Grimes.Ft struct lconv * 4958f0484fSRodney W. Grimes.Fn localeconv "void" 5058f0484fSRodney W. Grimes.Sh DESCRIPTION 5158f0484fSRodney W. GrimesThe 5258f0484fSRodney W. Grimes.Fn setlocale 5358f0484fSRodney W. Grimesfunction sets the C library's notion 5458f0484fSRodney W. Grimesof natural language formatting style 5558f0484fSRodney W. Grimesfor particular sets of routines. 5658f0484fSRodney W. GrimesEach such style is called a 5758f0484fSRodney W. Grimes.Sq locale 5858f0484fSRodney W. Grimesand is invoked using an appropriate name passed as a C string. 5958f0484fSRodney W. GrimesThe 6058f0484fSRodney W. Grimes.Fn localeconv 6158f0484fSRodney W. Grimesroutine returns the current locale's parameters 6258f0484fSRodney W. Grimesfor formatting numbers. 6358f0484fSRodney W. Grimes.Pp 6458f0484fSRodney W. GrimesThe 6558f0484fSRodney W. Grimes.Fn setlocale 6658f0484fSRodney W. Grimesfunction recognizes several categories of routines. 6758f0484fSRodney W. GrimesThese are the categories and the sets of routines they select: 6858f0484fSRodney W. Grimes.Pp 6958f0484fSRodney W. Grimes.Bl -tag -width LC_MONETARY 7058f0484fSRodney W. Grimes.It Dv LC_ALL 7158f0484fSRodney W. GrimesSet the entire locale generically. 7258f0484fSRodney W. Grimes.It Dv LC_COLLATE 7358f0484fSRodney W. GrimesSet a locale for string collation routines. 7458f0484fSRodney W. GrimesThis controls alphabetic ordering in 7558f0484fSRodney W. Grimes.Fn strcoll 7658f0484fSRodney W. Grimesand 7758f0484fSRodney W. Grimes.Fn strxfrm . 7858f0484fSRodney W. Grimes.It Dv LC_CTYPE 7958f0484fSRodney W. GrimesSet a locale for the 8058f0484fSRodney W. Grimes.Xr ctype 3 , 8158f0484fSRodney W. Grimes.Xr mbrune 3 , 8258f0484fSRodney W. Grimes.Xr multibyte 3 8358f0484fSRodney W. Grimesand 8458f0484fSRodney W. Grimes.Xr rune 3 8558f0484fSRodney W. Grimesfunctions. 8658f0484fSRodney W. GrimesThis controls recognition of upper and lower case, 8758f0484fSRodney W. Grimesalphabetic or non-alphabetic characters, 8858f0484fSRodney W. Grimesand so on. The real work is done by the 8958f0484fSRodney W. Grimes.Fn setrunelocale 9058f0484fSRodney W. Grimesfunction. 910b5e953bSAndrey A. Chernov.It Dv LC_MESSAGES 92271632b0SAndrey A. ChernovSet a locale for message catalogs, see 93271632b0SAndrey A. Chernov.Xr catopen 3 94271632b0SAndrey A. Chernovfunction. 9558f0484fSRodney W. Grimes.It Dv LC_MONETARY 9658f0484fSRodney W. GrimesSet a locale for formatting monetary values; 9758f0484fSRodney W. Grimesthis affects the 9858f0484fSRodney W. Grimes.Fn localeconv 9958f0484fSRodney W. Grimesfunction. 10058f0484fSRodney W. Grimes.It Dv LC_NUMERIC 10158f0484fSRodney W. GrimesSet a locale for formatting numbers. 10258f0484fSRodney W. GrimesThis controls the formatting of decimal points 10358f0484fSRodney W. Grimesin input and output of floating point numbers 10458f0484fSRodney W. Grimesin functions such as 10558f0484fSRodney W. Grimes.Fn printf 10658f0484fSRodney W. Grimesand 10758f0484fSRodney W. Grimes.Fn scanf , 10858f0484fSRodney W. Grimesas well as values returned by 10958f0484fSRodney W. Grimes.Fn localeconv . 11058f0484fSRodney W. Grimes.It Dv LC_TIME 11158f0484fSRodney W. GrimesSet a locale for formatting dates and times using the 11258f0484fSRodney W. Grimes.Fn strftime 11358f0484fSRodney W. Grimesfunction. 11458f0484fSRodney W. Grimes.El 11558f0484fSRodney W. Grimes.Pp 11658f0484fSRodney W. GrimesOnly three locales are defined by default, 11758f0484fSRodney W. Grimesthe empty string 11858f0484fSRodney W. Grimes.Li "\&""\|"" 11958f0484fSRodney W. Grimeswhich denotes the native environment, and the 12058f0484fSRodney W. Grimes.Li "\&""C"" 12158f0484fSRodney W. Grimesand 12258f0484fSRodney W. Grimes.LI "\&""POSIX"" 12358f0484fSRodney W. Grimeslocales, which denote the C language environment. 12458f0484fSRodney W. GrimesA 12558f0484fSRodney W. Grimes.Fa locale 12658f0484fSRodney W. Grimesargument of 12758f0484fSRodney W. Grimes.Dv NULL 12858f0484fSRodney W. Grimescauses 12958f0484fSRodney W. Grimes.Fn setlocale 13058f0484fSRodney W. Grimesto return the current locale. 13158f0484fSRodney W. GrimesBy default, C programs start in the 13258f0484fSRodney W. Grimes.Li "\&""C"" 13358f0484fSRodney W. Grimeslocale. 13458f0484fSRodney W. GrimesThe only function in the library that sets the locale is 13558f0484fSRodney W. Grimes.Fn setlocale ; 13658f0484fSRodney W. Grimesthe locale is never changed as a side effect of some other routine. 13758f0484fSRodney W. Grimes.Pp 13858f0484fSRodney W. GrimesThe 13958f0484fSRodney W. Grimes.Fn localeconv 14058f0484fSRodney W. Grimesfunction returns a pointer to a structure 14158f0484fSRodney W. Grimeswhich provides parameters for formatting numbers, 14258f0484fSRodney W. Grimesespecially currency values: 14358f0484fSRodney W. Grimes.Bd -literal -offset indent 14458f0484fSRodney W. Grimesstruct lconv { 14558f0484fSRodney W. Grimes char *decimal_point; 14658f0484fSRodney W. Grimes char *thousands_sep; 14758f0484fSRodney W. Grimes char *grouping; 14858f0484fSRodney W. Grimes char *int_curr_symbol; 14958f0484fSRodney W. Grimes char *currency_symbol; 15058f0484fSRodney W. Grimes char *mon_decimal_point; 15158f0484fSRodney W. Grimes char *mon_thousands_sep; 15258f0484fSRodney W. Grimes char *mon_grouping; 15358f0484fSRodney W. Grimes char *positive_sign; 15458f0484fSRodney W. Grimes char *negative_sign; 15558f0484fSRodney W. Grimes char int_frac_digits; 15658f0484fSRodney W. Grimes char frac_digits; 15758f0484fSRodney W. Grimes char p_cs_precedes; 15858f0484fSRodney W. Grimes char p_sep_by_space; 15958f0484fSRodney W. Grimes char n_cs_precedes; 16058f0484fSRodney W. Grimes char n_sep_by_space; 16158f0484fSRodney W. Grimes char p_sign_posn; 16258f0484fSRodney W. Grimes char n_sign_posn; 16358f0484fSRodney W. Grimes}; 16458f0484fSRodney W. Grimes.Ed 16558f0484fSRodney W. Grimes.Pp 16658f0484fSRodney W. GrimesThe individual fields have the following meanings: 16758f0484fSRodney W. Grimes.Pp 16858f0484fSRodney W. Grimes.Bl -tag -width mon_decimal_point 16958f0484fSRodney W. Grimes.It Fa decimal_point 17058f0484fSRodney W. GrimesThe decimal point character, except for currency values. 17158f0484fSRodney W. Grimes.It Fa thousands_sep 17258f0484fSRodney W. GrimesThe separator between groups of digits 17358f0484fSRodney W. Grimesbefore the decimal point, except for currency values. 17458f0484fSRodney W. Grimes.It Fa grouping 17558f0484fSRodney W. GrimesThe sizes of the groups of digits, except for currency values. 17658f0484fSRodney W. GrimesThis is a pointer to a vector of integers, each of size 17758f0484fSRodney W. Grimes.Va char , 17858f0484fSRodney W. Grimesrepresenting group size from low order digit groups 17958f0484fSRodney W. Grimesto high order (right to left). 18058f0484fSRodney W. GrimesThe list may be terminated with 0 or 18158f0484fSRodney W. Grimes.Dv CHAR_MAX . 18258f0484fSRodney W. GrimesIf the list is terminated with 0, 18358f0484fSRodney W. Grimesthe last group size before the 0 is repeated to account for all the digits. 18458f0484fSRodney W. GrimesIf the list is terminated with 18558f0484fSRodney W. Grimes.Dv CHAR_MAX , 18658f0484fSRodney W. Grimesno more grouping is performed. 18758f0484fSRodney W. Grimes.It Fa int_curr_symbol 18858f0484fSRodney W. GrimesThe standardized international currency symbol. 18958f0484fSRodney W. Grimes.It Fa currency_symbol 19058f0484fSRodney W. GrimesThe local currency symbol. 19158f0484fSRodney W. Grimes.It Fa mon_decimal_point 19258f0484fSRodney W. GrimesThe decimal point character for currency values. 19358f0484fSRodney W. Grimes.It Fa mon_thousands_sep 19458f0484fSRodney W. GrimesThe separator for digit groups in currency values. 19558f0484fSRodney W. Grimes.It Fa mon_grouping 19658f0484fSRodney W. GrimesLike 19758f0484fSRodney W. Grimes.Fa grouping 19858f0484fSRodney W. Grimesbut for currency values. 19958f0484fSRodney W. Grimes.It Fa positive_sign 20058f0484fSRodney W. GrimesThe character used to denote nonnegative currency values, 20158f0484fSRodney W. Grimesusually the empty string. 20258f0484fSRodney W. Grimes.It Fa negative_sign 20358f0484fSRodney W. GrimesThe character used to denote negative currency values, 20458f0484fSRodney W. Grimesusually a minus sign. 20558f0484fSRodney W. Grimes.It Fa int_frac_digits 20658f0484fSRodney W. GrimesThe number of digits after the decimal point 20758f0484fSRodney W. Grimesin an international-style currency value. 20858f0484fSRodney W. Grimes.It Fa frac_digits 20958f0484fSRodney W. GrimesThe number of digits after the decimal point 21058f0484fSRodney W. Grimesin the local style for currency values. 21158f0484fSRodney W. Grimes.It Fa p_cs_precedes 21258f0484fSRodney W. Grimes1 if the currency symbol precedes the currency value 21358f0484fSRodney W. Grimesfor nonnegative values, 0 if it follows. 21458f0484fSRodney W. Grimes.It Fa p_sep_by_space 21558f0484fSRodney W. Grimes1 if a space is inserted between the currency symbol 21658f0484fSRodney W. Grimesand the currency value for nonnegative values, 0 otherwise. 21758f0484fSRodney W. Grimes.It Fa n_cs_precedes 21858f0484fSRodney W. GrimesLike 21958f0484fSRodney W. Grimes.Fa p_cs_precedes 22058f0484fSRodney W. Grimesbut for negative values. 22158f0484fSRodney W. Grimes.It Fa n_sep_by_space 22258f0484fSRodney W. GrimesLike 22358f0484fSRodney W. Grimes.Fa p_sep_by_space 22458f0484fSRodney W. Grimesbut for negative values. 22558f0484fSRodney W. Grimes.It Fa p_sign_posn 22658f0484fSRodney W. GrimesThe location of the 22758f0484fSRodney W. Grimes.Fa positive_sign 22858f0484fSRodney W. Grimeswith respect to a nonnegative quantity and the 22958f0484fSRodney W. Grimes.Fa currency_symbol , 23058f0484fSRodney W. Grimescoded as follows: 23158f0484fSRodney W. Grimes.Bl -tag -width 3n -compact 23258f0484fSRodney W. Grimes.It Li 0 23358f0484fSRodney W. GrimesParentheses around the entire string. 23458f0484fSRodney W. Grimes.It Li 1 23558f0484fSRodney W. GrimesBefore the string. 23658f0484fSRodney W. Grimes.It Li 2 23758f0484fSRodney W. GrimesAfter the string. 23858f0484fSRodney W. Grimes.It Li 3 23958f0484fSRodney W. GrimesJust before 24058f0484fSRodney W. Grimes.Fa currency_symbol . 24158f0484fSRodney W. Grimes.It Li 4 24258f0484fSRodney W. GrimesJust after 24358f0484fSRodney W. Grimes.Fa currency_symbol . 24458f0484fSRodney W. Grimes.El 24558f0484fSRodney W. Grimes.It Fa n_sign_posn 24658f0484fSRodney W. GrimesLike 24758f0484fSRodney W. Grimes.Fa p_sign_posn 24858f0484fSRodney W. Grimesbut for negative currency values. 24958f0484fSRodney W. Grimes.El 25058f0484fSRodney W. Grimes.Pp 25158f0484fSRodney W. GrimesUnless mentioned above, 25258f0484fSRodney W. Grimesan empty string as a value for a field 25358f0484fSRodney W. Grimesindicates a zero length result or 25458f0484fSRodney W. Grimesa value that is not in the current locale. 25558f0484fSRodney W. GrimesA 25658f0484fSRodney W. Grimes.Dv CHAR_MAX 25758f0484fSRodney W. Grimesresult similarly denotes an unavailable value. 25858f0484fSRodney W. Grimes.Sh "RETURN VALUES 25958f0484fSRodney W. GrimesThe 26058f0484fSRodney W. Grimes.Fn setlocale 26158f0484fSRodney W. Grimesfunction returns 26258f0484fSRodney W. Grimes.Dv NULL 26358f0484fSRodney W. Grimesand fails to change the locale 26458f0484fSRodney W. Grimesif the given combination of 26558f0484fSRodney W. Grimes.Fa category 26658f0484fSRodney W. Grimesand 26758f0484fSRodney W. Grimes.Fa locale 26858f0484fSRodney W. Grimesmakes no sense. 26958f0484fSRodney W. GrimesThe 27058f0484fSRodney W. Grimes.Fn localeconv 27158f0484fSRodney W. Grimesfunction returns a pointer to a static object 27258f0484fSRodney W. Grimeswhich may be altered by later calls to 27358f0484fSRodney W. Grimes.Fn setlocale 27458f0484fSRodney W. Grimesor 27558f0484fSRodney W. Grimes.Fn localeconv . 27658f0484fSRodney W. Grimes.Sh FILES 27758f0484fSRodney W. Grimes.Bl -tag -width /usr/share/locale/locale/category -compact 27821b4da07SAndrey A. Chernov.It Pa $PATH_LOCALE/ Ns Em locale/category 2796a145130SMike Pritchard.It Pa /usr/share/locale/ Ns Em locale/category 2806a145130SMike Pritchardlocale file for the locale 2816a145130SMike Pritchard.Em locale 2826a145130SMike Pritchardand the category 2836a145130SMike Pritchard.Em category . 28458f0484fSRodney W. Grimes.El 28558f0484fSRodney W. Grimes.Sh "SEE ALSO 2868c9c6676SMike Pritchard.Xr colldef 1 , 2878c9c6676SMike Pritchard.Xr mklocale 1 , 288e69bcfc3SAlexander Langer.Xr ctype 3 , 28958f0484fSRodney W. Grimes.Xr mbrune 3 , 29058f0484fSRodney W. Grimes.Xr multibyte 3 , 29158f0484fSRodney W. Grimes.Xr rune 3 , 29258f0484fSRodney W. Grimes.Xr strcoll 3 , 29358f0484fSRodney W. Grimes.Xr strxfrm 3 , 294271632b0SAndrey A. Chernov.Xr catopen 3 , 2958c9c6676SMike Pritchard.Xr euc 4 , 29658f0484fSRodney W. Grimes.Xr utf2 4 29758f0484fSRodney W. Grimes.Sh STANDARDS 29858f0484fSRodney W. GrimesThe 29958f0484fSRodney W. Grimes.Fn setlocale 30058f0484fSRodney W. Grimesand 30158f0484fSRodney W. Grimes.Fn localeconv 30258f0484fSRodney W. Grimesfunctions conform to 30358f0484fSRodney W. Grimes.St -ansiC . 30458f0484fSRodney W. Grimes.Sh HISTORY 30558f0484fSRodney W. GrimesThe 30658f0484fSRodney W. Grimes.Fn setlocale 30758f0484fSRodney W. Grimesand 30858f0484fSRodney W. Grimes.Fn localeconv 3097bdf80e5SMike Pritchardfunctions first appeared in 3107bdf80e5SMike Pritchard.Bx 4.4 . 31158f0484fSRodney W. Grimes.Sh BUGS 31258f0484fSRodney W. GrimesThe current implementation supports only the 31358f0484fSRodney W. Grimes.Li "\&""C"" 31458f0484fSRodney W. Grimesand 31558f0484fSRodney W. Grimes.Li "\&""POSIX"" 316c28fbb7bSGarrett Wollmanlocales for all but the 317c28fbb7bSGarrett Wollman.Dv LC_COLLATE , 318c28fbb7bSGarrett Wollman.Dv LC_CTYPE , 319c28fbb7bSGarrett Wollmanand 320c28fbb7bSGarrett Wollman.Dv LC_TIME 321c28fbb7bSGarrett Wollmancategories. 32258f0484fSRodney W. Grimes.Pp 32358f0484fSRodney W. GrimesIn spite of the gnarly currency support in 32458f0484fSRodney W. Grimes.Fn localeconv , 32558f0484fSRodney W. Grimesthe standards don't include any functions 32658f0484fSRodney W. Grimesfor generalized currency formatting. 32758f0484fSRodney W. Grimes.Pp 32858f0484fSRodney W. GrimesUse of 32958f0484fSRodney W. Grimes.Dv LC_MONETARY 33058f0484fSRodney W. Grimescould lead to misleading results until we have a real time currency 33158f0484fSRodney W. Grimesconversion function. 33258f0484fSRodney W. Grimes.Dv LC_NUMERIC 33358f0484fSRodney W. Grimesand 33458f0484fSRodney W. Grimes.Dv LC_TIME 33558f0484fSRodney W. Grimesare personal choices and should not be wrapped up with the other categories. 336