home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
i18nv102.zip
/
SAMPLE
/
ULCASE
/
UL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-28
|
3KB
|
63 lines
/*****************************************************************************/
/*** Include files ***/
/*****************************************************************************/
#include <stdio.h> /* Standard IO functions. */
#include <wchar.h> /* XPG/4 library. */
#include <locale.h> /* Locale definitions. */
/*****************************************************************************/
/*** Global defines ***/
/*****************************************************************************/
#define UPPER_LIMIT 0xFF /* Maximum character to check. */
/*****************************************************************************/
/*** Case conversions for characters. ***/
/*****************************************************************************/
void do_case_functions(void)
{
int ch; /* Character to check. */
/* Print out the current locale name.*/
printf("The current locale is: %s\n\n", setlocale(LC_CTYPE, NULL));
/* Print a banner. */
printf("Table of case conversions for characters:\n");
printf("-----------------------------------------\n");
/* For each character... */
/* If the character is alpha... */
/* If the character can be */
/* converted to lowercase, */
/* print it out. */
/* If the character can be */
/* converted to uppercase, */
/* print it out. */
for (ch = 0; ch <= UPPER_LIMIT; ++ch)
{
if (isalpha(ch))
{
if (tolower(ch) != ch)
printf("'%c' converted to lowercase is: '%c'\n", ch, tolower(ch));
if (toupper(ch) != ch)
printf("'%c' converted to uppercase is: '%c'\n", ch, toupper(ch));
}
}
}
/*****************************************************************************/
/*** Main program ***/
/*****************************************************************************/
void main(void)
{
/* Set the locale based on env var. */
setlocale(LC_ALL, "");
/* Print out upper/lower case table. */
do_case_functions();
}