Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    int mblen( const char *s, size_t n );

Description:
    The mblen function determines the number of bytes comprising the
    multibyte character pointed to by s.  At most n bytes of the array
    pointed to by s will be examined.

Returns:
    If s is a NULL pointer, the mblen function returns zero if multibyte
    character encodings do not have state-dependent encoding, and non-zero
    otherwise.  If s is not a NULL pointer, the mblen function returns:

    0
        if s points to the null character

    len
        the number of bytes that comprise the multibyte character (if the
        next n or fewer bytes form a valid multibyte character)

    -1
        if the next n bytes do not form a valid multibyte character


See Also:
    mbtowc, mbstowcs, wctomb, wcstombs

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void main()
      {
        int     len;
        char    *mbs = "string";

        printf( "Character encodings do %shave "
                "state-dependent encoding\n",
                ( mblen( NULL, 0 ) )
                ? "" : "not " );

        len = mblen( "string", 6 );
        if( len != -1 ) {
          mbs[len] = '\0';
          printf( "Multibyte char '%s'(%d)\n", mbs, len );
        }
      }

    produces the following:

    Character encodings do not have state-dependent encoding
    Multibyte char 's'(1)

Classification:
    ANSI

Systems:
    All

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson