Back to index

glibc  2.9
Functions | Variables
mblen.c File Reference
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <gconv.h>
#include <wcsmbs/wcsmbsload.h>

Go to the source code of this file.


int mblen (const char *s, size_t n)


static mbstate_t state

Function Documentation

int mblen ( const char *  s,
size_t  n 

Definition at line 34 of file mblen.c.

  int result;

  /* If S is NULL the function has to return null or not null
     depending on the encoding having a state depending encoding or
     not.  */
  if (s == NULL)
      const struct gconv_fcts *fcts;

      /* Get the conversion functions.  */
      fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));

      /* Reset the state.  */
      memset (&state, '\0', sizeof state);

      result = fcts->towc->__stateful;
  else if (*s == '\0')
    /* According to the ISO C 89 standard this is the expected behaviour.  */
    result = 0;
      memset (&state, '\0', sizeof state);

      result = __mbrtowc (NULL, s, n, &state);

      /* The `mbrtowc' functions tell us more than we need.  Fold the -1
        and -2 result into -1.  */
      if (result < 0)
       result = -1;

  return result;

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

mbstate_t state [static]

Definition at line 27 of file mblen.c.