std:: wcscspn
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Null-terminated wide strings
| Functions | ||||||||||||||||||||||||||
| Character classification | ||||||||||||||||||||||||||
| Character manipulation | ||||||||||||||||||||||||||
| Conversions to numeric formats | ||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||
| String manipulation | ||||||||||||||||||||||||||
| String examination | ||||||||||||||||||||||||||
| Array manipulation | ||||||||||||||||||||||||||
|
ヘッダーで定義
<cwchar>
|
||
|
std::
size_t
wcscspn
(
const
wchar_t
*
dest,
const
wchar_t
*
src
)
;
|
||
dest が指すワイド文字列の最大の初期セグメントの長さを返します。このセグメントは、 src が指すワイド文字列に含まれない文字のみで構成されます。
目次 |
パラメータ
| dest | - | 解析対象のヌル終端ワイド文字列へのポインタ |
| src | - | 検索対象の文字を含むヌル終端ワイド文字列へのポインタ |
戻り値
src が指す文字列に含まれない文字のみで構成される最大の先頭セグメントの長さ。
例
以下の出力はclang(libc++)を使用して得られたものです。
このコードを実行
#include <cwchar> #include <iostream> #include <locale> int main() { wchar_t dest[] = L"白猫 黑狗 甲虫"; // └───┐ const wchar_t* src = L"甲虫,黑狗"; const std::size_t len = std::wcscspn(dest, src); dest[len] = L'\0'; // terminates the segment to print it out std::wcout.imbue(std::locale("en_US.utf8")); std::wcout << L"The length of maximum initial segment is " << len << L".\n"; std::wcout << L"The segment is \"" << dest << L"\".\n"; }
出力例:
The length of maximum initial segment is 3. The segment is "白猫 ".
関連項目
|
他のワイド文字列に含まれるワイド文字のみで構成される
最大の先頭セグメントの長さを返す (関数) |
|
|
あるワイド文字列中の任意のワイド文字が、
別のワイド文字列で最初に現れる位置を検索する (関数) |
|
|
Cドキュメント
for
wcscspn
|
|