在线文档教程
C++
字符串 | Strings

std::wcscoll

性病:

Defined in header
int wcscoll( const wchar_t* lhs, const wchar_t* rhs

根据最近安装的区域设置比较两个以空结尾的宽字符串。std::setlocale属性定义的LC_COLLATE类别。

参数

lhs, rhs-pointers to the null-terminated wide strings to compare

返回值

负值lhs少于%28先于%29rhs...

​0​如果lhs等于rhs...

正值lhs大于%28跟随%29rhs...

注记

排序顺序是字典顺序:字母在国家字母中的位置等价类%29比它的情况或变体有更高的优先级。在等价类中,小写字符在大写等价物和特定于地区的顺序之前进行排序,可以适用于具有对话式的字符。在某些地区,一组字符比较起来是单个的。校对单位例如,"ch"捷克文如下"h"先于"i",和"dzs"匈牙利文如下"dz"先于"g"...

二次

#include <iostream> #include <clocale> void try_compare(const wchar_t* p1, const wchar_t* p2) { if(std::wcscoll(p1, p2) < 0) std::wcout << p1 << " before " << p2 << '\n'; else std::wcout << p2 << " before " << p1 << '\n'; } int main() { std::setlocale(LC_ALL, "en_US.utf8" std::wcout << "In the American locale: "; try_compare(L"hrnec", L"chrt" std::setlocale(LC_COLLATE, "cs_CZ.utf8" std::wcout << "In the Czech locale: "; try_compare(L"hrnec", L"chrt" std::setlocale(LC_COLLATE, "en_US.utf8" std::wcout << "In the American locale: "; try_compare(L"år", L"ängel" std::setlocale(LC_COLLATE, "sv_SE.utf8" std::wcout << "In the Swedish locale: "; try_compare(L"år", L"ängel" }

二次

产出:

二次

In the American locale: chrt before hrnec In the Czech locale: hrnec before chrt In the American locale: ängel before år In the Swedish locale: år before ängel

二次

另见

strcollcompares two strings in accordance to the current locale (function)
do_compare virtualcompares two strings using this facet's collation rules (virtual protected member function of std::collate)
wcsxfrmtransform a wide string so that wcscmp would produce the same result as wcscoll (function)

C文件

© cppreference.com

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

http://en.cppreference.com/w/cpp/string/Wide/wccoll