Software Internationalization Guide

POSIX and XPG Internationalization Model
Software Internationalization Guide526225-002
3-7
Messaging System
This example uses hard-coded values to check that a character is within the
boundaries of the ASCII code set:
/* Hard code ASCII range */
main()
{
int input;
input = getchar();
if ((input >= 65 && input <= 90) || (input >= 97 && input <=
122))
process_valid_char(input);
else
process_invalid_char(input);
}
This example uses the internationalized function isalpha() to verify that a character
is within the boundaries of a code set defined by the current locale setting:
/* Use isalpha() function */
main ()
{
int input;
setlocale(LC_ALL,"");
input = getchar();
if (isalpha(input))
process_valid_char(input);
else
process_invalid_char(input);
}
The second example provides much more flexibility than the first because the locale
can change and the program still functions as it should. It contains no hard-coded,
locale-dependent values as does the first example.
Messaging System
An international messaging system enables creating, storing, and accessing user-
visible text in several languages. A messaging system helps the localization process
by isolating message text from program source code and storing the text in separate
message source files.
Programmers create message source files, then use a utility to create message
catalogs from the message source files. The message catalogs can then be localized
into different languages without affecting program source code—it is not necessary to
modify or recompile the program source code because of changes to message text. At
run time, the program accesses the appropriate localized message catalog through a
set of internationalized function calls.
Message source files are used as input to three utilities: mkcatdefs, gencat, and
runcat. The mkcatdefs utility preprocesses a message text source file to change