CKTIS / C
wcslen — wide-string length
wcslen from <wchar.h> returns the number of wchar_t elements before the first null wide character, excluding that terminator.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <wchar.h>
size_t wcslen(const wchar_t *s);wcslen(s) returns a wide string's length as size_t. It counts wchar_t elements, not bytes or user-perceived characters. It does not measure array capacity.
s must point to a valid null-terminated wide string. Passing NULL or omitting the terminator within the accessible array causes undefined behavior; the function accepts no read limit.
In the example, L"cat\0dog" contains an embedded terminator, so the result is 3. The %zu conversion prints a size_t value.
Examples
#include <stdio.h>
#include <wchar.h>
int main(void)
{
const wchar_t text[] = L"cat\0dog";
printf("%zu\n", wcslen(text));
return 0;
}Result
3
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.