/************************************************************************ * * * Copyright Digital Equipment Corporation 1998. All rights reserved. * * * * Restricted Rights: Use, duplication, or disclosure by the U.S. * * Government is subject to restrictions as set forth in subparagraph * * (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR * * 52.227-14 Alt. III, as applicable. * * * * This software is proprietary to and embodies the confidential * * technology of Digital Equipment Corporation. Possession, use, or * * copying of this software and media is authorized only pursuant to a * * valid written license from Digital or an authorized sublicensor. * * * ************************************************************************/ /* nl_langinfo_example.c */ #include #include #include /* This test sets up the British English locale, and then inquires on the */ /* data and time format, first day of the week, and abbreviated first */ /* day of the week. */ #include #include int main() { char *return_val; char *nl_ptr; /* set the locale, with user supplied locale name */ return_val = setlocale(LC_ALL, "en_gb.iso8859-1"); if (return_val == NULL) { printf("ERROR : The locale is unknown"); exit(1); } printf("+-----------------------------------------------------+\n"); /* Get the date and time format from the locale. */ printf("D_T_FMT = "); /* Compare the returned string from nl_langinfo with an empty */ /* string. */ if (!strcmp((nl_ptr = (char *) nl_langinfo(D_T_FMT)), "")) { /* The string returned was empty this could mean that either */ /* 1) The locale does not contain a value for this item */ /* 2) The value for this item is an empty string */ printf("nl_langinfo returned an empty string\n"); } else { /* Display the date and time format */ printf("%s\n", nl_ptr); } /* Get the full name for the first day of the week from locale */ printf("DAY_1 = "); /* Compare the returned string from nl_langinfo with an empty */ /* string. */ if (!strcmp((nl_ptr = (char *) nl_langinfo(DAY_1)), "")) { /* The string returned was empty this could mean that either */ /* 1) The locale does not contain a value for the first day of */ /* the week */ /* 2) The value for the first day of the week is an empty string */ printf("nl_langinfo returned an empty string\n"); } else { /* Display the full name of the first day of the week */ printf("%s\n", nl_ptr); } /* Get the abbreviated name for the first day of the week from locale */ printf("ABDAY_1 = "); /* Compare the returned string from nl_langinfo with an empty */ /* string. */ if (!strcmp((nl_ptr = (char *) nl_langinfo(ABDAY_1)), "")) { /* The string returned was empty this could mean that either */ /* 1) The locale does not contain a value for the first day of */ /* the week */ /* 2) The value for the first day of the week is an empty string */ printf("nl_langinfo returned an empty string\n"); } else { /* Display the abbreviated name of the first day of the week */ printf("%s\n", nl_ptr); } }