std::wcscoll
cppreference.com
<tbody>
</tbody>
int wcscoll( const wchar_t* lhs, const wchar_t* rhs ); |
||
| lhs, rhs |
, lhs () rhs.
0, lhs rhs.
, lhs ( ) rhs.
: ( ) , . , . . , "ch" "h" "i", "dzs" "dz" "g".
#include <clocale>
#include <iostream>
void try_compare(const wchar_t* p1, const wchar_t* p2)
{
if (std::wcscoll(p1, p2) < 0)
std::wcout << p1 << L" " << p2 << '\n';
else
std::wcout << p2 << L" " << p1 << '\n';
}
int main()
{
std::setlocale(LC_ALL, "en_US.utf8");
std::wcout << L" : ";
try_compare(L"hrnec", L"chrt");
std::setlocale(LC_COLLATE, "cs_CZ.utf8");
std::wcout << L" : ";
try_compare(L"hrnec", L"chrt");
std::setlocale(LC_COLLATE, "en_US.utf8");
std::wcout << L" : ";
try_compare(L"r", L"ngel");
std::setlocale(LC_COLLATE, "sv_SE.utf8");
std::wcout << L" : ";
try_compare(L"r", L"ngel");
}
:
: chrt before hrnec
: hrnec before chrt
: ngel before r
: r before ngel
| () | |
[virtual] |
(virtual protected std::collate -)
|
| , wcscmp , wcscoll () | |
C wcscoll
| |