From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/string%2Fwide%2Fwcscoll.html | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 devdocs/c/string%2Fwide%2Fwcscoll.html (limited to 'devdocs/c/string%2Fwide%2Fwcscoll.html') diff --git a/devdocs/c/string%2Fwide%2Fwcscoll.html b/devdocs/c/string%2Fwide%2Fwcscoll.html new file mode 100644 index 00000000..d011acc3 --- /dev/null +++ b/devdocs/c/string%2Fwide%2Fwcscoll.html @@ -0,0 +1,58 @@ +

wcscoll

Defined in header <wchar.h>
int wcscoll( const wchar_t *lhs, const wchar_t *rhs );
+
(since C95)

Compares two null-terminated wide strings according to the collation order defined by the LC_COLLATE category of the currently installed locale.

+

Parameters

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

Return value

Negative value if lhs is less than (precedes) rhs.

+

​0​ if lhs is equal to rhs.

+

Positive value if lhs is greater than (follows) rhs.

+

Notes

Collation order is the dictionary order: the position of the letter in the national alphabet (its equivalence class) has higher priority than its case or variant. Within an equivalence class, lowercase characters collate before their uppercase equivalents and locale-specific order may apply to the characters with diacritics. In some locales, groups of characters compare as single collation units. For example, "ch" in Czech follows "h" and precedes "i", and "dzs" in Hungarian follows "dz" and precedes "g".

+

Example

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

Possible output:

+
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

References

See also

+ + + +
compares two strings in accordance to the current locale
(function)
+
(C95)
transform a wide string so that wcscmp would produce the same result as wcscoll
(function)
+
(C95)
compares two wide strings
(function)
C++ documentation for wcscoll
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/string/wide/wcscoll +

+
-- cgit v1.2.3