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.4 2005/12/10 00:22:28 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.Aq Pa 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.Pp 104.Bd -literal -offset indent 105#include <time.h> 106#include <langinfo.h> 107#include <locale.h> 108 109int main(void) 110{ 111 char datestring[100]; 112 struct tm *tm; 113 time_t t; 114 char *ptr; 115 116 t = time(NULL); 117 tm = localtime(&t); 118 (void)setlocale(LC_ALL, ""); 119 ptr = nl_langinfo(D_T_FMT); 120 strftime(datestring, sizeof(datestring), ptr, tm); 121 printf("%s\en",datestring); 122 return (0); 123} 124.Ed 125.\" .Pp 126.\" The following example uses 127.\" .Fn nl_langinfo 128.\" to obtain the setting of the currency symbol for the current locale: 129.\" .Pp 130.\" .Bd 131.\" #include <langinfo.h> 132.\" #include <locale.h> 133.\" int main(void) 134.\" { 135.\" char *ptr; 136.\" (void)setlocale(LC_ALL, ""); 137.\" ptr = nl_langinfo(CRNCYSTR); 138.\" printf("%s", ptr); 139.\" } 140.\" .Ed 141.Sh SEE ALSO 142.Xr setlocale 3 , 143.Xr nls 7 144.Sh STANDARDS 145The 146.Fn nl_langinfo 147function conforms to 148.St -p1003.1-2001 . 149.Sh HISTORY 150The 151.Fn nl_langinfo 152function appeared in 153.Nx 1.0 . 154