1MBLEN(P)                   POSIX Programmer's Manual                  MBLEN(P)
2
3
4

NAME

6       mblen - get number of bytes in a character
7

SYNOPSIS

9       #include <stdlib.h>
10
11       int mblen(const char *s, size_t n);
12
13

DESCRIPTION

15       If s is not a null pointer, mblen() shall determine the number of bytes
16       constituting the character pointed to by s. Except that the shift state
17       of mbtowc() is not affected, it shall be equivalent to:
18
19
20              mbtowc((wchar_t *)0, s, n);
21
22       The  implementation shall behave as if no function defined in this vol‐
23       ume of IEEE Std 1003.1-2001 calls mblen().
24
25       The behavior of this function is affected by the LC_CTYPE  category  of
26       the current locale. For a state-dependent encoding, this function shall
27       be placed into its initial state by a  call  for  which  its  character
28       pointer  argument,  s,  is  a  null pointer. Subsequent calls with s as
29       other than a null pointer shall cause the internal state of  the  func‐
30       tion  to be altered as necessary. A call with s as a null pointer shall
31       cause this function to return a non-zero value if encodings have  state
32       dependency,  and  0  otherwise.  If  the implementation employs special
33       bytes to change the shift state, these bytes shall not produce separate
34       wide-character  codes, but shall be grouped with an adjacent character.
35       Changing the LC_CTYPE category causes the shift state of this  function
36       to be unspecified.
37

RETURN VALUE

39       If  s is a null pointer, mblen() shall return a non-zero or 0 value, if
40       character encodings, respectively, do or do  not  have  state-dependent
41       encodings.  If  s  is not a null pointer, mblen() shall either return 0
42       (if s points to the null byte), or return the number of bytes that con‐
43       stitute  the character (if the next n or fewer bytes form a valid char‐
44       acter), or return -1 (if they do not form a valid character)   and  may
45       set  errno  to indicate the error.  In no case shall the value returned
46       be greater than n or the value of the {MB_CUR_MAX} macro.
47

ERRORS

49       The mblen() function may fail if:
50
51       EILSEQ Invalid character sequence is detected.
52
53
54       The following sections are informative.
55

EXAMPLES

57       None.
58

APPLICATION USAGE

60       None.
61

RATIONALE

63       None.
64

FUTURE DIRECTIONS

66       None.
67

SEE ALSO

69       mbtowc() , mbstowcs() , wctomb() , wcstombs() ,  the  Base  Definitions
70       volume of IEEE Std 1003.1-2001, <stdlib.h>
71
73       Portions  of  this text are reprinted and reproduced in electronic form
74       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
75       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
76       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
77       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
78       event of any discrepancy between this version and the original IEEE and
79       The  Open Group Standard, the original IEEE and The Open Group Standard
80       is the referee document. The original Standard can be  obtained  online
81       at http://www.opengroup.org/unix/online.html .
82
83
84
85IEEE/The Open Group                  2003                             MBLEN(P)
Impressum