optu16to8 man page on MirBSD

Man page or keyword search:  
man Server   6113 pages
apropos Keyword Search (all sections)
Output format
MirBSD logo
[printable version]

WCRTOMB(3)		   BSD Programmer's Manual		    WCRTOMB(3)

NAME
     optu16to8, wcrtomb - converts a wide character to a multibyte character
     (restartable)

SYNOPSIS
     #include <wchar.h>

     size_t
     optu16to8(char * restrict s, wchar_t wc, mbstate_t * restrict ps);

     size_t
     wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps);

DESCRIPTION
     wcrtomb() converts the wide character given by wc to the corresponding
     multibyte character, and stores it in the array pointed to by s unless s
     is a null pointer. This function will modify the first at most MB_CUR_MAX
     bytes of the array pointed by s, if ps is an initial conversion state.
     Contrary to and violating Version 3 of the Single UNIX Specification,
     this implementation can store more bytes in s if ps is not the initial
     conversion state. Starting with MirOS #10, MB_CUR_MAX has been adjusted
     to accomodate this fact, from the old value of "3" to a new value of "5"
     calculated by the formula "(old-MB_CUR_MAX * 2) - 1".

     The behaviour of wcrtomb() is affected by the LC_CTYPE category of the
     current locale.

     optu16to8() behaves similar to wcrtomb(), but always converts from
     OPTU-16 to OPTU-8 encoding, independent of the current locale.

     These are the special cases:

     wc == 0	   For state-dependent encodings, wcrtomb() stores a null byte
		   preceded by a special byte sequence (if any) to return to
		   an initial state to the array pointed by s, and the state
		   object pointed by ps also returned to a initial state.

     s == NULL	   wcrtomb() just places ps into a initial state. It is
		   equivalent to the following call:

			 wcrtomb(buf, L'\0', ps);

		   Here, buf is a dummy buffer. In this case, wc is ignored.

     ps == NULL	   mbrtowc() uses its own internal state object to keep the
		   conversion state, instead of ps mentioned in this manual
		   page.

		   Calling any other functions in libc never changes the
		   internal states of optu16to8() or mbrtowc(), which are ini-
		   tialised at startup time of the program.

RETURN VALUES
     optu16to8() and wcrtomb() return:

     positive	   The number of bytes (including any shift sequences) which
		   are stored in the array.

     (size_t)-1	   wc is not a valid wide character. In this case, wcrtomb()
		   also sets errno to indicate error.

ERRORS
     optu16to8() and wcrtomb() may cause an error in the following cases:

     [EILSEQ]	   wc is not a valid wide character.

     [EINVAL]	   ps points to an invalid or uninitialised mbstate_t object.

SEE ALSO
     iswoctet(3), optu8to16(3), setlocale(3), wctomb(3)

STANDARDS
     The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 ("ISO C90,
     Amendment 1"). The restrict qualifier is added at ISO/IEC 9899/1999 ("ISO
     C99").

     At present, MirOS is limited to the Unicode BMP (Basic Multilingual
     Plane), thus OPTU-8 is limited to the common subset of CESU-8 and UTF-8.

HISTORY
     The optu16to8 function first appeared in MirOS #11.

AUTHORS
     Thorsten Glaser <tg@mirbsd.de> wrote the entire internationalisation im-
     plementation in MirOS. He is also the steward for the OPTU encoding.

CAVEATS
     On a system whose wide character type is only 16 bits wide, as opposed to
     31 bits of ISO 10646, the OPTU encoder and decoder are permitted to not
     de- and recompose any surrogates encountered and pass them through as if
     they were regular wide characters with no special function. Since MirOS
     is such a system, the reference implementation does not care about UTF-16
     surrogates posing as OPTU-16 characters at all; a planes-aware Unicode
     application is required to handle surrogates by itself. For compatibility
     purposes, optu16to8 should always be assumed to not treat surrogates spe-
     cially; applications must ensure to not produce invalid surrogates unless
     limited to the BMP.

MirOS BSD #10-current		March 17, 2010				     1
[top]

List of man pages available for MirBSD

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net