1.\" $NetBSD: nl_langinfo.3,v 1.12 2003/07/26 19:24:46 salo Exp $ 2.\" 3.\" Written by J.T. Conklin <jtc@NetBSD.org>. 4.\" Public domain. 5.\" 6.Dd February 12, 2003 7.Dt NL_LANGINFO 3 8.Os 9.Sh NAME 10.Nm nl_langinfo 11.Nd get locale information 12.Sh LIBRARY 13.Lb libc 14.Sh SYNOPSIS 15.In langinfo.h 16.Ft char * 17.Fn nl_langinfo "nl_item item" 18.Sh DESCRIPTION 19The 20.Fn nl_langinfo 21function returns a pointer to a string containing information 22set by the program's locale. 23.Pp 24The names and values of 25.Fa item 26are defined in 27.Aq langinfo.h . 28The entries under Category indicate in which 29.Xr setlocale 3 30category each item is defined. 31.sp 32.nf 33.ta \w'ERA_D_T_FMT'u+1n +\w'LC_MESSAGES'u+1n +\w'Name of the third day of the week (e.g.: Tuesday)'u 34\fIConstant\fP \fICategory\fP \fIMeaning\fP 35.ta \w'ERA_D_T_FMT'u+1n +\w'LC_MESSAGES'u+1n +\w'Name of the third day of the week (e.g.: Tuesday)'u+1nC 36.sp 5p 37CODESET LC_CTYPE Codeset name 38D_T_FMT LC_TIME String for formatting date and time 39D_FMT LC_TIME Date format string 40T_FMT LC_TIME Time format string 41T_FMT_AMPM LC_TIME a.m. or p.m. time format string 42AM_STR LC_TIME Ante-meridiem affix 43PM_STR LC_TIME Post-meridiem affix 44DAY_1 LC_TIME Name of the first day of the week (e.g.: Sunday) 45DAY_2 LC_TIME Name of the second day of the week (e.g.: Monday) 46DAY_3 LC_TIME Name of the third day of the week (e.g.: Tuesday) 47DAY_4 LC_TIME Name of the fourth day of the week (e.g.: Wednesday) 48DAY_5 LC_TIME Name of the fifth day of the week (e.g.: Thursday) 49DAY_6 LC_TIME Name of the sixth day of the week (e.g.: Friday) 50DAY_7 LC_TIME Name of the seventh day of the week (e.g.: Saturday) 51ABDAY_1 LC_TIME Abbreviated name of the first day of the week 52ABDAY_2 LC_TIME Abbreviated name of the second day of the week 53ABDAY_3 LC_TIME Abbreviated name of the third day of the week 54ABDAY_4 LC_TIME Abbreviated name of the fourth day of the week 55ABDAY_5 LC_TIME Abbreviated name of the fifth day of the week 56ABDAY_6 LC_TIME Abbreviated name of the sixth day of the week 57ABDAY_7 LC_TIME Abbreviated name of the seventh day of the week 58MON_1 LC_TIME Name of the first month of the year 59MON_2 LC_TIME Name of the second month 60MON_3 LC_TIME Name of the third month 61MON_4 LC_TIME Name of the fourth month 62MON_5 LC_TIME Name of the fifth month 63MON_6 LC_TIME Name of the sixth month 64MON_7 LC_TIME Name of the seventh month 65MON_8 LC_TIME Name of the eighth month 66MON_9 LC_TIME Name of the ninth month 67MON_10 LC_TIME Name of the tenth month 68MON_11 LC_TIME Name of the eleventh month 69MON_12 LC_TIME Name of the twelfth month 70ABMON_1 LC_TIME Abbreviated name of the first month 71ABMON_2 LC_TIME Abbreviated name of the second month 72ABMON_3 LC_TIME Abbreviated name of the third month 73ABMON_4 LC_TIME Abbreviated name of the fourth month 74ABMON_5 LC_TIME Abbreviated name of the fifth month 75ABMON_6 LC_TIME Abbreviated name of the sixth month 76ABMON_7 LC_TIME Abbreviated name of the seventh month 77ABMON_8 LC_TIME Abbreviated name of the eighth month 78ABMON_9 LC_TIME Abbreviated name of the ninth month 79ABMON_10 LC_TIME Abbreviated name of the tenth month 80ABMON_11 LC_TIME Abbreviated name of the eleventh month 81ABMON_12 LC_TIME Abbreviated name of the twelfth month 82ERA LC_TIME Era description segments 83ERA_D_FMT LC_TIME Era date format string 84ERA_D_T_FMT LC_TIME Era date and time format string 85ERA_T_FMT LC_TIME Era time format string 86ALT_DIGITS LC_TIME Alternative symbols for digits 87RADIXCHAR LC_NUMERIC Radix character 88THOUSEP LC_NUMERIC Separator for thousands 89YESEXPR LC_MESSAGES Affirmative response expression 90NOEXPR LC_MESSAGES Negative response expression 91.\" CRNCYSTR LC_MONETARY Local currency symbol 92.fi 93.Sh RETURN VALUES 94.Fn nl_langinfo 95returns a pointer to an empty string if 96.Fa item 97is invalid. 98.Sh EXAMPLES 99The following example uses 100.Fn nl_langinfo 101to obtain the date and time format for the current locale: 102.Pp 103.Bd -literal 104 #include <time.h> 105 #include <langinfo.h> 106 #include <locale.h> 107 int main(void) 108 { 109 char datestring[100]; 110 struct tm *tm; 111 time_t t; 112 char *ptr; 113 t = time(NULL); 114 tm = localtime(&t); 115 (void)setlocale(LC_ALL, ""); 116 ptr = nl_langinfo(D_T_FMT); 117 strftime(datestring, sizeof(datestring), ptr, tm); 118 printf("%s\n",datestring); 119 return (0); 120 } 121.Ed 122.\" .Pp 123.\" The following example uses 124.\" .Fn nl_langinfo 125.\" to obtain the setting of the currency symbol for the current locale: 126.\" .Pp 127.\" .Bd 128.\" #include <langinfo.h> 129.\" #include <locale.h> 130.\" int main(void) 131.\" { 132.\" char *ptr; 133.\" (void)setlocale(LC_ALL, ""); 134.\" ptr = nl_langinfo(CRNCYSTR); 135.\" printf("%s", ptr); 136.\" } 137.\" .Ed 138.Sh SEE ALSO 139.Xr setlocale 3 , 140.Xr nls 7 141.Sh STANDARDS 142The 143.Fn nl_langinfo 144function conforms to 145.St -p1003.1-2001 . 146.Sh HISTORY 147The 148.Fn nl_langinfo 149function appeared in 150.Nx 1.0 . 151