std::wcsspn(3)
πΈ NAME πΈ
okay so this is std::wcsspn(3), from the C++ Standard Libary (yes, thatβs the manual name, typo and all π), and sheβs here to explain the wide-character βhow long is this matching prefixβ situation. iconic π
std::wcsspn - std::wcsspn β¨
β¨ Synopsis β¨
Defined in header <cwchar>:
size_t wcsspn( const wchar_t* dest, const wchar_t* src );
Returns the length of the maximum initial segment of the wide string pointed to by dest, that consists of only the characters found in wide string pointed to by src. Thatβs the whole vibe, bestie β prefix matching but make it wide π¦.
π Parameters π
destβ pointer to the null-terminated wide string to be analyzed πΈsrcβ pointer to the null-terminated wide string that contains the characters to search for π
π Return value π
The length of the maximum initial segment that contains only characters from the wide string pointed to by src. periodt π
π§ Example π§
Run this code, bestie:
// Run this code
#include <cwchar>
#include <iostream>
#include <locale>
int main()
{
wchar_t dest[] = L"η½η« ι»η η²θ«";
const wchar_t src[] = L" ηη« η½ι» ";
const std::size_t len = std::wcsspn(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";
}
Possible output:
The length of maximum initial segment is 6.
The segment is "η½η« ι»η ".
π¦ See also π¦
wcscspnβ function that returns the length of the maximum initial segment that consists of only the wide characters not found in another wide string πwcspbrkβ function that finds the first location of any wide character in one wide string, in another wide string π- C documentation for
wcsspnπ
Source/version/date tea β: this page is from http://cppreference.com, with the 2024.06.10 version/date stamp. Bye bestie, go slay some wide strings! π
β¨π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms