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. 15fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 1658f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 1758f0484fSRodney W. Grimes.\" without specific prior written permission. 1858f0484fSRodney W. Grimes.\" 1958f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2058f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2158f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2258f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2358f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2458f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2558f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2658f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2758f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2858f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2958f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3058f0484fSRodney W. Grimes.\" 31eef7327aSGordon Bergling.Dd August 7, 2020 3258f0484fSRodney W. Grimes.Dt SETLOCALE 3 3358f0484fSRodney W. Grimes.Os 3458f0484fSRodney W. Grimes.Sh NAME 35da44487bSTim J. Robbins.Nm setlocale 3658f0484fSRodney W. Grimes.Nd natural language formatting for C 3725bb73e0SAlexey Zelkin.Sh LIBRARY 3825bb73e0SAlexey Zelkin.Lb libc 3958f0484fSRodney W. Grimes.Sh SYNOPSIS 4032eef9aeSRuslan Ermilov.In locale.h 4158f0484fSRodney W. Grimes.Ft char * 4258f0484fSRodney W. Grimes.Fn setlocale "int category" "const char *locale" 4358f0484fSRodney W. Grimes.Sh DESCRIPTION 4458f0484fSRodney W. GrimesThe 4558f0484fSRodney W. Grimes.Fn setlocale 4658f0484fSRodney W. Grimesfunction sets the C library's notion 4758f0484fSRodney W. Grimesof natural language formatting style 4858f0484fSRodney W. Grimesfor particular sets of routines. 4958f0484fSRodney W. GrimesEach such style is called a 5058f0484fSRodney W. Grimes.Sq locale 5158f0484fSRodney W. Grimesand is invoked using an appropriate name passed as a C string. 5258f0484fSRodney W. Grimes.Pp 5358f0484fSRodney W. GrimesThe 5458f0484fSRodney W. Grimes.Fn setlocale 5558f0484fSRodney W. Grimesfunction recognizes several categories of routines. 5658f0484fSRodney W. GrimesThese are the categories and the sets of routines they select: 5758f0484fSRodney W. Grimes.Bl -tag -width LC_MONETARY 5858f0484fSRodney W. Grimes.It Dv LC_ALL 5958f0484fSRodney W. GrimesSet the entire locale generically. 6058f0484fSRodney W. Grimes.It Dv LC_COLLATE 6158f0484fSRodney W. GrimesSet a locale for string collation routines. 6258f0484fSRodney W. GrimesThis controls alphabetic ordering in 6358f0484fSRodney W. Grimes.Fn strcoll 6458f0484fSRodney W. Grimesand 6558f0484fSRodney W. Grimes.Fn strxfrm . 6658f0484fSRodney W. Grimes.It Dv LC_CTYPE 6758f0484fSRodney W. GrimesSet a locale for the 6831d330fbSTim J. Robbins.Xr ctype 3 6958f0484fSRodney W. Grimesand 7031d330fbSTim J. Robbins.Xr multibyte 3 7158f0484fSRodney W. Grimesfunctions. 7258f0484fSRodney W. GrimesThis controls recognition of upper and lower case, 7358f0484fSRodney W. Grimesalphabetic or non-alphabetic characters, 741a0a9345SRuslan Ermilovand so on. 750b5e953bSAndrey A. Chernov.It Dv LC_MESSAGES 76271632b0SAndrey A. ChernovSet a locale for message catalogs, see 77271632b0SAndrey A. Chernov.Xr catopen 3 78271632b0SAndrey A. Chernovfunction. 7958f0484fSRodney W. Grimes.It Dv LC_MONETARY 8058f0484fSRodney W. GrimesSet a locale for formatting monetary values; 8158f0484fSRodney W. Grimesthis affects the 8258f0484fSRodney W. Grimes.Fn localeconv 8358f0484fSRodney W. Grimesfunction. 8458f0484fSRodney W. Grimes.It Dv LC_NUMERIC 8558f0484fSRodney W. GrimesSet a locale for formatting numbers. 8658f0484fSRodney W. GrimesThis controls the formatting of decimal points 8758f0484fSRodney W. Grimesin input and output of floating point numbers 8858f0484fSRodney W. Grimesin functions such as 8958f0484fSRodney W. Grimes.Fn printf 9058f0484fSRodney W. Grimesand 9158f0484fSRodney W. Grimes.Fn scanf , 9258f0484fSRodney W. Grimesas well as values returned by 9358f0484fSRodney W. Grimes.Fn localeconv . 9458f0484fSRodney W. Grimes.It Dv LC_TIME 9558f0484fSRodney W. GrimesSet a locale for formatting dates and times using the 9658f0484fSRodney W. Grimes.Fn strftime 9758f0484fSRodney W. Grimesfunction. 98eef7327aSGordon Bergling.It Dv LANG 99eef7327aSGordon BerglingSets the generic locale category for native language, local customs 100eef7327aSGordon Berglingand coded character set in the absence of more specific locale 101eef7327aSGordon Berglingvariables. 10258f0484fSRodney W. Grimes.El 10358f0484fSRodney W. Grimes.Pp 10458f0484fSRodney W. GrimesOnly three locales are defined by default, 10558f0484fSRodney W. Grimesthe empty string 1063d05ebbcSUlrich Spörlein.Li \&"\|" 10758f0484fSRodney W. Grimeswhich denotes the native environment, and the 1083d05ebbcSUlrich Spörlein.Li \&"C" 10958f0484fSRodney W. Grimesand 1103d05ebbcSUlrich Spörlein.Li \&"POSIX" 11158f0484fSRodney W. Grimeslocales, which denote the C language environment. 11258f0484fSRodney W. GrimesA 11358f0484fSRodney W. Grimes.Fa locale 11458f0484fSRodney W. Grimesargument of 11558f0484fSRodney W. Grimes.Dv NULL 11658f0484fSRodney W. Grimescauses 11758f0484fSRodney W. Grimes.Fn setlocale 11858f0484fSRodney W. Grimesto return the current locale. 11972adb2c0SJoerg Wunsch.Pp 12072adb2c0SJoerg WunschThe option 12172adb2c0SJoerg Wunsch.Fl a 12272adb2c0SJoerg Wunschto the 12372adb2c0SJoerg Wunsch.Xr locale 1 12472adb2c0SJoerg Wunschcommand can be used to display all further possible names for the 12572adb2c0SJoerg Wunsch.Fa locale 12672adb2c0SJoerg Wunschargument that are recognized. 12772adb2c0SJoerg WunschSpecifying any unrecognized value for 12872adb2c0SJoerg Wunsch.Fa locale 12972adb2c0SJoerg Wunschmakes 13072adb2c0SJoerg Wunsch.Fn setlocale 13172adb2c0SJoerg Wunschfail. 13272adb2c0SJoerg Wunsch.Pp 13358f0484fSRodney W. GrimesBy default, C programs start in the 1343d05ebbcSUlrich Spörlein.Li \&"C" 13558f0484fSRodney W. Grimeslocale. 13672adb2c0SJoerg Wunsch.Pp 13758f0484fSRodney W. GrimesThe only function in the library that sets the locale is 13858f0484fSRodney W. Grimes.Fn setlocale ; 13958f0484fSRodney W. Grimesthe locale is never changed as a side effect of some other routine. 140f80eb0cbSRuslan Ermilov.Sh RETURN VALUES 141f80eb0cbSRuslan ErmilovUpon successful completion, 142ecffe713SAndrey A. Chernov.Fn setlocale 143f80eb0cbSRuslan Ermilovreturns the string associated with the specified 144ecffe713SAndrey A. Chernov.Fa category 145ecffe713SAndrey A. Chernovfor the requested 146ecffe713SAndrey A. Chernov.Fa locale . 14758f0484fSRodney W. GrimesThe 14858f0484fSRodney W. Grimes.Fn setlocale 14958f0484fSRodney W. Grimesfunction returns 15058f0484fSRodney W. Grimes.Dv NULL 15158f0484fSRodney W. Grimesand fails to change the locale 15258f0484fSRodney W. Grimesif the given combination of 15358f0484fSRodney W. Grimes.Fa category 15458f0484fSRodney W. Grimesand 15558f0484fSRodney W. Grimes.Fa locale 15658f0484fSRodney W. Grimesmakes no sense. 157*f6d234d8SGordon Bergling.Sh FILES 158*f6d234d8SGordon Bergling.Bl -tag -width /usr/share/locale/locale/category -compact 159*f6d234d8SGordon Bergling.It Pa $PATH_LOCALE/ Ns Em locale/category 160*f6d234d8SGordon Bergling.It Pa /usr/share/locale/ Ns Em locale/category 161*f6d234d8SGordon Berglinglocale file for the locale 162*f6d234d8SGordon Bergling.Em locale 163*f6d234d8SGordon Berglingand the category 164*f6d234d8SGordon Bergling.Em category . 165*f6d234d8SGordon Bergling.El 166eef7327aSGordon Bergling.Sh EXAMPLES 167eef7327aSGordon BerglingThe following code illustrates how a program can initialize the 168eef7327aSGordon Berglinginternational environment for one language, while selectively 169eef7327aSGordon Berglingmodifying the program's locale such that regular expressions and 170eef7327aSGordon Berglingstring operations can be applied to text recorded in a different 171eef7327aSGordon Berglinglanguage: 172eef7327aSGordon Bergling.Bd -literal 173eef7327aSGordon Bergling setlocale(LC_ALL, "de"); 174eef7327aSGordon Bergling setlocale(LC_COLLATE, "fr"); 175eef7327aSGordon Bergling.Ed 176eef7327aSGordon Bergling.Pp 177eef7327aSGordon BerglingWhen a process is started, its current locale is set to the C or POSIX 178eef7327aSGordon Berglinglocale. 179eef7327aSGordon BerglingAn internationalized program that depends on locale data not defined in 180eef7327aSGordon Berglingthe C or POSIX locale must invoke the setlocale subroutine in the 181eef7327aSGordon Berglingfollowing manner before using any of the locale-specific information: 182eef7327aSGordon Bergling.Bd -literal 183eef7327aSGordon Bergling setlocale(LC_ALL, ""); 184eef7327aSGordon Bergling.Ed 18524a0682cSRuslan Ermilov.Sh ERRORS 18624a0682cSRuslan ErmilovNo errors are defined. 187f80eb0cbSRuslan Ermilov.Sh SEE ALSO 18872adb2c0SJoerg Wunsch.Xr locale 1 , 189b3f9b738SBaptiste Daroussin.Xr localedef 1 , 190acd80190SWolfram Schneider.Xr catopen 3 , 191e69bcfc3SAlexander Langer.Xr ctype 3 , 192da44487bSTim J. Robbins.Xr localeconv 3 , 19358f0484fSRodney W. Grimes.Xr multibyte 3 , 19458f0484fSRodney W. Grimes.Xr strcoll 3 , 19558f0484fSRodney W. Grimes.Xr strxfrm 3 , 1968962b7a5STim J. Robbins.Xr euc 5 , 197e6e9fb74SAndrey A. Chernov.Xr utf8 5 , 198e6e9fb74SAndrey A. Chernov.Xr environ 7 19958f0484fSRodney W. Grimes.Sh STANDARDS 20058f0484fSRodney W. GrimesThe 20158f0484fSRodney W. Grimes.Fn setlocale 202da44487bSTim J. Robbinsfunction conforms to 203f4da1a75STim J. Robbins.St -isoC-99 . 20458f0484fSRodney W. Grimes.Sh HISTORY 20558f0484fSRodney W. GrimesThe 20658f0484fSRodney W. Grimes.Fn setlocale 207da44487bSTim J. Robbinsfunction first appeared in 2087bdf80e5SMike Pritchard.Bx 4.4 . 209