首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::wcslen

Defined in header <cwchar>

std::size_t wcslen( const wchar_t* str );

返回宽字符串的长度,即终止空宽字符之前的非空宽字符数。

所指向的宽字符数组中没有空字符,则行为未定义。str...

参数

str

-

pointer to the null-terminated wide string to be examined

返回值

以空结尾的宽字符串的长度。str...

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
The length of "爆ぜろリアル!弾けろシナプス!パニッシュメントディス、ワールド!" is 32

二次

另见

strlen

returns the length of a given string (function)

mblen

returns the number of bytes in the next multibyte character (function)

c.wcslen文件

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券