std::wcslen
来自cppreference.com
空终止宽字符串
| 函数 | |||||||||||||||||||||
| 字符操作 | |||||||||||||||||||||
| 转换到数值格式 | |||||||||||||||||||||
|
|
||||||||||||||||||||
| 字符串操作 | |||||||||||||||||||||
| 数组操作 | |||||||||||||||||||||
|
在标头
<cwchar>
定义
|
||
|
std::size_t
wcslen( const wchar_t* str );
|
||
返回宽字符串的长度,即空终止宽字符之前的非空宽字符数。
若 str 所指向的宽字符数组中无空字符则行为未定义。
参数
| str | - | 指向要检验的空终止宽字符串的指针 |
返回值
空终止宽字符串 str 的长度。
示例
运行此代码
#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'; }
输出:
The length of "歡迎來到加帕里公園" is 9
参阅
| 返回给定字符串的长度 (函数) |
|
| 返回下一个多字节字符中的字节数 (函数) |