Simplified Chinese Solaris User's Guide

Conversion Utilities

The conversion functions described in this section are available, but you should use iconv() as a standard function.

Simplified Chinese Solaris software provides facilities for various conversions, for example:

Programs using the general multibyte conversion utilities should include the header files widec.h and wctype.h. Simplified Chinese Solaris specific routines (such as iscxxx) are declared in zh/xctype.h.

Programs using general multibyte conversion utilities should include three header files: wctype.h, widec.h, and zh/xctype.h.

The locale/xctype.h file declares the Chinese locale-specific routines, which have names of the form iscxxxx:

As with the classification functions described in the previous section, the use of these functions can be controlled by the setlocale function (described elsewhere in this and other chapters).

Locale-specific conversion routines (such as Chinese cgbtoeuc) are contained in the libcle library:

This library can be linked during compilation using the C compiler option -lcle.

Conversion Within a Codeset

The multibyte conversion functions are similar to the one-byte conversion functions toupper and tolower. These functions convert wide-characters to other wide characters. For more information on conversion routines, see the man pages for wconv(3) and cconv(3).

The following routines are in the regular Chinese C library:

Table A-3 Simplified Chinese Case Conversion Functions (declared in zh/xctype.h)

Function 

Description 

tocupper

Converts codeset 1 Roman lowercase to uppercase 

toclower

Converts codeset 1 Roman uppercase to lowercase 

Conversion Between Simplified Chinese Codesets

In the Simplified Chinese character sets, the Roman characters and numbers in codeset 0 are repeated in codeset 1. The following functions test wide characters.

Table A-4 Simplified Chinese Codeset Conversion Functions

Function 

Description 

atocgb

Converts alphabetic or numeric characters in ASCII (codeset 0) to the corresponding characters in GB-2312-80 (codeset 1). 

cgbtoa

Converts alphabetic or numeric characters in GB-2312-80 (codeset 1) to the corresponding characters in ASCII (codeset 0). 

For further information on these functions, see the man page for cconv()(3x).