Software Internationalization Guide

The HP Internationalization Subsystem
Software Internationalization Guide526225-002
4-5
Preparing Source Code
Data Transparency
Make sure your program source code is data transparent. In data transparent code, no
data bits is used to represent a non-data character.
Data transparency is a fundamental requirement for internationalized applications
because internationalized software must be able to support numerous single-byte or
multibyte code sets. In most single-byte code sets, all eight bits are used for encoding
characters; in multibyte code sets, more than eight bits are needed.
Do not use bit masks to set or test for specific bits. For example, do not use 0x80 in
the eighth bit as a flag.
Hard-Coded Messages
Remove all hard-coded messages from the program source code and store them in a
separate file or files. Replace the hard-coded messages with function calls to retrieve
messages from the message file.
Here is an example of a hard-coded message:
printf("Hello World");
Instead of hard-coding messages, use the messaging system. This example uses the
catgets() function to retrieve a message from a message catalog:
/* default string is included in function call */
printf("%s", catgets(catd,1,1,"Hello World"));
If no localized message is available, the application uses the fourth parameter of the
catgets() function as the default message.
Culturally Dependent Information
Culturally dependent information reflects a particular language or culture and is specific
to a locale. Examples of culturally dependent information include date, time, and
monetary formats. Internationalizing software requires removing all hard-coded
culturally dependent information from the program source code.
Here is an example of a hard-coded date format:
printf("The date is %s/%s/%s", month, day, year);
Instead of hard-coding the date format, isolate locale-specific date formats from the
program source code, and use internationalized functions to write locale-independent
code. This example displays the current day:
char * dptr;
.
.
.
strftime (dptr, MAXSIZE, "%A", tptr);
printf ("%s %s", catgets (catd,1,1,"Today is "), dptr);