1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS CRT 4 * PURPOSE: Implementation of _mbsnlen 5 * FILE: lib/sdk/crt/string/_mbsnlen.c 6 * PROGRAMMER: Timo Kreuzer 7 */ 8 9 #include <mbstring.h> 10 11 _Check_return_ 12 _CRTIMP 13 size_t 14 __cdecl 15 _mbsnlen( 16 _In_z_ const unsigned char *pmbstr, 17 _In_ size_t cjMaxLen) 18 { 19 size_t cchCount = 0; 20 unsigned char jMbsByte; 21 22 /* Loop while we have bytes to process */ 23 while (cjMaxLen-- > 0) 24 { 25 /* Get next mb byte */ 26 jMbsByte = *pmbstr++; 27 28 /* If this is 0, we're done */ 29 if (jMbsByte == 0) break; 30 31 /* Don't count lead bytes */ 32 if (!_ismbblead(jMbsByte)) cchCount++; 33 } 34 35 return cchCount; 36 } 37