std:: wcscoll
|
ヘッダーで定義
<cwchar>
|
||
|
int
wcscoll
(
const
wchar_t
*
lhs,
const
wchar_t
*
rhs
)
;
|
||
現在設定されているロケール( std::setlocale で最後に設定されたもの)に基づき、 LC_COLLATE カテゴリで定義される方法で、2つのヌル終端ワイド文字列を比較します。
目次 |
パラメータ
| 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 << " 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
関連項目
|
現在のロケールに従って2つの文字列を比較する
(関数) |
|
|
[virtual]
|
このファセットの照合規則を使用して2つの文字列を比較する
(
std::collate<CharT>
の仮想保護メンバー関数)
|
ワイド文字列を変換して、
wcscmp
が
wcscoll
と同じ結果を生成するようにする
(関数) |
|
|
Cドキュメント
for
wcscoll
|
|