.\" Copyright (c) 1993 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" %sccs.include.redist.roff%
.\" @(#)multibyte.3 5.2 (Berkeley) %G%
.Nd multibyte character support for C
.Fn mblen "const char *mbchar" "int nbytes"
.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars"
.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes"
.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes"
.Fn wctomb "char *mbchar" "wchar_t wchar"
The basic elements of some written natural languages such as Chinese
cannot be represented uniquely with single C
The C standard supports two different ways of dealing with
extended natural language encodings,
Wide characters are an internal representation
which allows each basic element to map
to a single object of type
Multibyte characters are used for input and output
and code each basic element as a sequence of C
Individual basic elements may map into one or more
bytes in a multibyte character.
governs the interpretation of wide and multibyte characters.
specifically controls this interpretation.
type is wide enough to hold the largest value
in the wide character representations for all locales.
Multibyte strings may contain
indicators to switch to and from
particular modes within the given representation.
If explicit bytes are used to signal shifting,
these are not recognized as separate characters
but are lumped with a neighboring character.
There is always a distinguished
functions assume that multibyte strings are interpreted
starting from the initial shift state.
functions maintain static shift state internally.
pointer returns nonzero if the current locale requires shift states,
if shift states are required, the shift state is reset to the initial state.
The internal shift states are undefined after a call to
For convenience in processing,
the wide character with value 0
.Pq the null wide character
is recognized as the wide character string terminator,
and the character with value 0
is recognized as the multibyte character string terminator.
Null bytes are not permitted within multibyte characters.
function computes the length in bytes
function converts a multibyte character
into a wide character and stores the result
in the object pointed to by
function converts a wide character
into a multibyte character and stores
must be large enough to accommodate the multibyte character.
function converts a multibyte character string
into a wide character string
wide characters are stored.
A terminating null wide character is appended if there is room.
function converts a wide character string
into a multibyte character string
Partial multibyte characters at the end of the string are not stored.
The multibyte character string is null terminated if there is room.
If multibyte characters are not supported in the current locale,
all of these functions will return \-1 if characters can be processed,
functions return nonzero if shift states are supported,
then these functions return
the number of bytes processed in
or \-1 if no multibyte character
could be recognized or converted.
function returns the number of wide characters converted,
not counting any terminating null wide character.
function returns the number of bytes converted,
not counting any terminating null byte.
If any invalid multibyte characters are encountered,
both functions return \-1.
The current implementation does not support shift states.