Software Internationalization Guide

The HP Internationalization Subsystem
Software Internationalization Guide526225-002
4-6
Locale-Sensitive Functions
The application takes the localized “Today is” phrase from the message catalog,
and strftime() provides the day. If the locale is English, the preceding example
displays “Today is Thursday”; the Italian locale results in “Oggi è giovedì”; the Spanish
locale results in “Hoy es jueves.” If no localized message is available, the application
uses the fourth parameter of the catgets() function as the default message.
Character Encoding
Remove all assumptions about character encoding from program source code. This
example checks if a character is alphabetic, but assumes that ASCII encoding has
been used:
if ((C >= 65 && C <= 90) || (C >= 97 && C <= 122))
printf ("Valid Entry");
Instead of making encoding assumptions, use internationalized functions such as
isalpha() to write locale-independent code:
if (isalpha(c))
printf("%s", catgets(catd,1,1,"Valid Entry"));
Locale-Sensitive Functions
Internationalized functions enable character-based data to be processed independently
of the underlying character encoding. Internationalized functions are standard C
language functions that have been enhanced to handle languages and code sets other
than US English and the ASCII coded character set. Internationalized functions are
locale-sensitive, which means that their results vary at run time depending upon the
current locale of the application.
ISO/ANSI C Functions
The ISO C standard includes functions that operate in an international environment.
The following table lists these functions and identifies those whose behavior is locale
sensitive (LS), based on the target compilation environment. The compilation
environment is set with the SYSTYPE pragma.
Note. Locale sensitivity is available only for the OSS environment. This includes program
modules compiled for the Guardian environment and bound into an OSS program.
Table 4-1. ISO/ANSI C Functions (page 1 of 3)
ISO/ANSI C
function
OSS and Guardian
TNS/R native
module
OSS TNS module Guardian TNS
module
atof() LS C/POSIX only C/POSIX only
atoi() LS C/POSIX only C/POSIX only
atol() LS C/POSIX only C/POSIX only