std::wcslen
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Text processing library
Regular expressions library (C++11)
Formatting library (C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++26)
Null-terminated wide strings
(C++11)
(C++11)(C++11)
Defined in header
<cwchar>
std::size_t wcslen( const wchar_t* str );
Returns the length of a wide string, that is the number of non-null wide characters that precede the terminating null wide character.
The behavior is undefined if there is no null character in the wide character array pointed to by str.
[edit] Parameters
str
-
pointer to the null-terminated wide string to be examined
[edit] Return value
The length of the null-terminated wide string str.
[edit] Possible implementation
std::size_t wcslen(const wchar_t* start) { // NB: start is not checked for nullptr! const wchar_t* end = start; while (*end != L'0円') ++end; return end - start; }
[edit] Example
Run this code
#include <iostream> #include <cwchar> int main() { const wchar_t* str = L"Hello, world!"; std::wcout << "The length of L\"" << str << "\" is " << std::wcslen(str) << '\n'; }
Output:
The length of L"Hello, world!" is 13
[edit] See also
C documentation for wcslen