[CMAKE]
[reactos.git] / lib / sdk / crt / mbstring / mbstrlen.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/sdk/crt/mbstring/mbstrlen.c
5 * PURPOSE: Determines the length of a multi byte string, current locale
6 * PROGRAMERS:
7 * Copyright 1999 Alexandre Julliard
8 * Copyright 2000 Jon Griffths
9 *
10 */
11
12 #include <mbstring.h>
13 #include <stdlib.h>
14
15 #ifdef _LIBCNT_
16 unsigned short *NlsLeadByteInfo;
17 #define isleadbyte(c) NlsLeadByteInfo[c]
18 #else
19 int isleadbyte(int byte);
20 #endif
21
22 /*
23 * @implemented
24 */
25 size_t _mbstrlen( const char *str )
26 {
27 size_t len = 0;
28 while(*str)
29 {
30 /* FIXME: According to the documentation we are supposed to test for
31 * multi-byte character validity. Whatever that means
32 */
33 str += isleadbyte(*str) ? 2 : 1;
34 len++;
35 }
36 return len;
37 }