Avoid Hard-coding
Minimize hard-cording of country-, code-page- or device-unique information
in your program.
- Utilize query functions of the system.
- If no appropriate system functions are available,
isolate such information from executable code.
Following are the advantages of the single module programming style:
- A single object module can support both SBCS
and DBCS languages. If your program is running on SBCS code pages, the
contents of the environment vector are nulls and your check logic just recognizes
all bytes as SBCS characters (although you may separate logics for SBCS
from those for DBCS if performance is critical for your product).
- A single object module can support all DBCS languages
since your program will not contain such country-unique information but
rather get the information from the system at run time.
- Your program can be flexible to the addition
of new code pages supported in DBCS OS/2. For example, if the relation
between code pages and the vectors are hard-coded in your program for previous
OS/2 version, your program should be modified to support the code pages
which are new to the later OS/2 version.
[Back: For both SBCS and DBCS]
[Next: Run-Time Dynamic Link of DBCS OS/2 Unique Functions]