Internationalizing and Localizing Applications in Oracle Solaris

Exit Print View

Updated: July 2014
 
 

Conversion Between Multibyte and Wide Characters

The following functions are used for conversion between the codeset of the current locale (multibyte) and the process code (wide-character representation).

These functions are locale sensitive and depend on the LC_CTYPE category of the current locale. They return the same error on incomplete characters and illegal characters. For more information on illegal characters and incomplete characters, see Converting Codesets

mblen()

Get the number of bytes in a character

mbtowc()

Convert a character to a wide-character code

mbstowcs()

Convert a character string to a wide-character string

wctomb()

Convert a wide-character code to a character

wcstombs()

Convert a wide-character string to a character string

The following functions are restartable, and can be used to handle incomplete character cases. These cases occur when an incomplete character reported from the previous call along with the additional bytes of the current call is a valid character. In order to store the state information required for this kind of processing, the functions either use a user-provided or an internal state structure of type mbstate_t. The mbsinit() function is used to detect whether an mbstate_t structure is in an initial state.

mbsinit()

Determine the conversion object status

mbrlen()

Get the number of bytes in a character (restartable)

mbrtowc()

Convert a character to a wide-character code (restartable)

mbsrtowcs()

Convert a character string to a wide-character string (restartable)

wcrtomb()

Convert a wide-character code to a character (restartable)

wcsrtombs()

Convert a wide-character string to a character string (restartable)

The following functions are used for conversion between the codeset of the current locale and the process code. They determine whether the integer-coded character is represented in single-byte. If not, they return EOF and WEOF respectively.

wctob()

Convert a wide-character to a single-byte character, if possible

btowc()

Convert a single-byte character to a wide character, if possible