Asian Application Developer's Guide

Conversion Utilities

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

Asian 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.

Programs using general multibyte conversion utilities should include three header files: wctype.h, widec.h, plus one of the following locale-specific files:

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

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

Locale-specific conversion routines (such as Korean comptopack or Chinese cgbtoeuc are contained in a locale-specific library:

This library can be linked during compilation using the C compiler option:

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) for all locales and for:

The following routines are in the regular Chinese C library:

Table B-5 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 

Table B-6 Traditional Chinese Case Conversion Functions (declared in zh_TW/xctype.h)

Function 

Description 

tohupper

Converts codeset 1 Roman lowercase to uppercase 

tohlower

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 B-7 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).

Conversion for Korean Character Codes

The following routines perform character-based code conversion on the KS C 5601 character set. They convert characters between Completion code (or EUC format) and Combination code (or Packed code).

To use these routines, the library kle must be linked using the C compiler option -lkle. For more information, see the kconv(3x) man page.

Table B-8 Korean Code Conversion Functions

Routine 

Description 

comptopack

Converts a character in Completion code to Combination (Packed) code of KS C 5601-1987. 

packtocomp

Converts a character in Combination (Packed) code of KS C 5601-1987 to Completion code.  

wansuntojohap

Converts a character in Completion code to Combination (Packed) code of KS C 5601-1992. 

packtocomp

Converts a character in Combination (Packed) code of KS C 5601-1992 to Completion code .