- Wrap change of entries in an InitChange/ExitChange pair (without this,
[AROS.git] / compiler / stdc / mblen.c
blob3bfb0dadb6163e84ad79bf8b2cb75f28ab267205
1 /*
2 Copyright © 2004-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function mblen().
6 */
8 #include <aros/debug.h>
10 /*****************************************************************************
12 NAME */
13 #include <stdlib.h>
15 int mblen(
17 /* SYNOPSIS */
18 const char *s,
19 size_t n)
21 /* FUNCTION
22 This function returns the number of bytes of the next multi-byte
23 character.
25 INPUTS
26 s: string pointer to look at next multi-byte character.
27 n: The maximum number of bytes to look at.
29 RESULT
30 if s is not NULL will return the length in bytes of the next
31 multi-byte character in s; 0 is return when it is a NULL
32 byte character; -1 if it is not a valid multi-byte character.
33 If s is NULL zero or non-zero is returned when multi-byte encodings
34 resp. don't or do have state-dependent encodings.
36 NOTES
37 stdc.library currently only implements the "C" locale
38 This means that either 0 or 1 is returned when s is not NULL.
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 ******************************************************************************/
50 if (s == NULL)
51 /* No state-dependent encondings */
52 return 0;
54 if (n == 0 || *s == '\0')
55 return 0;
57 if (isascii(*s))
58 return 1;
59 else
60 return -1;