std::wcslen
| 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.
Contents |
[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: no nullptr checking! const wchar_t* end = start; for( ; *end != L'\0'; ++end) ; return end - start; } |
[edit] Example
#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::wcslen(str) << '\n'; }
Output:
The length of "爆ぜろリアル!弾けろシナプス!パニッシュメントディス、ワールド!" is 32
[edit] See also
| returns the length of a given string (function) | |
| returns the number of bytes in the next multibyte character (function) | |
| C documentation for wcslen
| |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
