2008-12-18 21:17:22 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: lib/sdk/crt/mbstring/mbstrlen.c
|
|
|
|
* PURPOSE: Determines the length of a multi byte string, current locale
|
|
|
|
* PROGRAMERS:
|
|
|
|
* Copyright 1999 Alexandre Julliard
|
|
|
|
* Copyright 2000 Jon Griffths
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
#include <mbstring.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2010-11-05 22:21:36 +00:00
|
|
|
#ifdef _LIBCNT_
|
|
|
|
unsigned short *NlsLeadByteInfo;
|
|
|
|
#define isleadbyte(c) NlsLeadByteInfo[c]
|
|
|
|
#else
|
2008-12-18 21:17:22 +00:00
|
|
|
int isleadbyte(int byte);
|
2010-11-05 22:21:36 +00:00
|
|
|
#endif
|
2008-12-18 21:17:22 +00:00
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2015-09-15 10:35:49 +00:00
|
|
|
size_t __cdecl _mbstrlen( const char *str )
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2008-12-18 21:17:22 +00:00
|
|
|
size_t len = 0;
|
|
|
|
while(*str)
|
|
|
|
{
|
|
|
|
/* FIXME: According to the documentation we are supposed to test for
|
|
|
|
* multi-byte character validity. Whatever that means
|
|
|
|
*/
|
2012-12-16 16:38:36 +00:00
|
|
|
str += isleadbyte((unsigned char)*str) ? 2 : 1;
|
2008-12-18 21:17:22 +00:00
|
|
|
len++;
|
|
|
|
}
|
|
|
|
return len;
|
2007-03-14 20:24:57 +00:00
|
|
|
}
|