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