FreeBSD Manual Pages
std::wcslen(3) C++ Standard Libary std::wcslen(3) NAME std::wcslen - std::wcslen Synopsis 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. Parameters str - pointer to the null-terminated wide string to be examined Return value The length of the null-terminated wide string str. Possible implementation std::size_t wcslen(const wchar_t* start) { // NB: no nullptr checking! const wchar_t* end = start; for( ; *end != L'\0'; ++end) ; return end - start; } Example // Run this code #include <iostream> #include <cwchar> #include <clocale> int main() { const wchar_t* str = L""; std::setlocale(LC_ALL, "en_US.utf8"); std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << "The length of \"" << str << "\" is " << std::wc- slen(str) << '\n'; } Output: The length of "" is 32 See also strlen returns the length of a given string (function) mblen returns the number of bytes in the next multibyte character (function) http://cppreference.com 2022.07.31 std::wcslen(3)
NAME | Synopsis | Parameters | Return value | Possible implementation | Example | Output: | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::wcslen&sektion=3&manpath=FreeBSD+Ports+15.0>
