Coded character set independence in developing applications

You can ensure that you are working effectively with the locale functionality if you use the appropriate functions, macros, and tools. Figure 1 is a summary of the compile-edit work flow and shows which functions to use and where you can use them.

Figure 1. Compile-edit, related to locale function
Graphic of compile-edit, related to locale function
 1 
Setup. The localedef information (see overview in Customizing a locale and details in Locale source files).
 2 
Coded character set of source code, header files, and data. The compiler must support the coded character set used to create a source file so that it will recognize the variant C syntax characters correctly.
  • The #pragma filetag directive identifies the coded character set of the source file as well as the library or user's include files (for an overview see The pragma filetag directive)
  • Predefined macros __LOCALE__, __FILETAG__, and __CODESET__ (for an overview see Using predefined macros)
  • The function setlocale()
  • The pragma convlit directive
  • The pragma convert directive
 3 
Coded character set conversion utilities and functions. The coded character set of a file, or a stream of data, can be converted to another coded character set using the utilities genxlt and iconv (for an overview see Code set conversion utilities; for the details of the utilities and functions, see z/OS XL C/C++ User's Guide), as well as the functions in the runtime library.
 4 
Coded character set conversion at compile time is determined by the compile-time locale and supported by the compiler options, LOCALE and NOLOCALE (for an overview, see Converting coded character sets at compile time; for details, see LOCALE in z/OS XL C/C++ User's Guide).
 5 
Runtime environment. During run time, the setlocale() function has an effect on runtime functions, such as printf(), scanf(), and regcomp(), which use variant characters.
 6 
Listings and output files. The coded character set used to create or to convert source files may affect listings, preprocessed source code, object modules, and SYSEVENT files (for an overview see Object modules and output listings). Your application can, however, include logic using the following to minimize the impact:
  • __LOCALE__, __FILETAG__, and __CODESET__ macros
  • Locale functions such as setlocale()