summaryrefslogtreecommitdiff
path: root/devdocs/c/string%2Fbyte%2Fstrcoll.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/string%2Fbyte%2Fstrcoll.html
new repository
Diffstat (limited to 'devdocs/c/string%2Fbyte%2Fstrcoll.html')
-rw-r--r--devdocs/c/string%2Fbyte%2Fstrcoll.html60
1 files changed, 60 insertions, 0 deletions
diff --git a/devdocs/c/string%2Fbyte%2Fstrcoll.html b/devdocs/c/string%2Fbyte%2Fstrcoll.html
new file mode 100644
index 00000000..8c19e000
--- /dev/null
+++ b/devdocs/c/string%2Fbyte%2Fstrcoll.html
@@ -0,0 +1,60 @@
+ <h1 id="firstHeading" class="firstHeading">strcoll</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;string.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl"> <td class="t-dcl-nopad"> <pre data-language="c">int strcoll( const char* lhs, const char* rhs );</pre>
+</td> <td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> </table> <p>Compares two null-terminated byte strings according to the current locale as defined by the <code><a href="../../locale/lc_categories" title="c/locale/LC categories">LC_COLLATE</a></code> category.</p>
+<h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> lhs, rhs </td> <td> - </td> <td> pointers to the null-terminated byte strings to compare </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <ul>
+<li> Negative value if <code>lhs</code> is <i>less than</i> (precedes) <code>rhs</code>. </li>
+<li> <code>​0​</code> if <code>lhs</code> is <i>equal to</i> <code>rhs</code>. </li>
+<li> Positive value if <code>lhs</code> is <i>greater than</i> (follows) <code>rhs</code>. </li>
+</ul> <h3 id="Notes"> Notes</h3> <p>Collation order is the dictionary order: the position of the letter in the national alphabet (its <i>equivalence class</i>) 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 <i>collation units</i>. For example, <code>"ch"</code> in Czech follows <code>"h"</code> and precedes <code>"i"</code>, and <code>"dzs"</code> in Hungarian follows <code>"dz"</code> and precedes <code>"g"</code>.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;locale.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;string.h&gt;
+
+int main(void)
+{
+ setlocale(LC_COLLATE, "cs_CZ.utf8");
+ // Alternatively, ISO-8859-2 (a.k.a. Latin-2)
+ // may also work on some OS:
+ // setlocale(LC_COLLATE, "cs_CZ.iso88592");
+
+ const char* s1 = "hrnec";
+ const char* s2 = "chrt";
+
+ printf("In the Czech locale: ");
+ if (strcoll(s1, s2) &lt; 0)
+ printf("%s before %s\n", s1, s2);
+ else
+ printf("%s before %s\n", s2, s1);
+
+ printf("In lexicographical comparison: ");
+ if (strcmp(s1, s2) &lt; 0)
+ printf("%s before %s\n", s1, s2);
+ else
+ printf("%s before %s\n", s2, s1);
+}</pre></div> <p>Output:</p>
+<div class="text source-text"><pre data-language="c">In the Czech locale: hrnec before chrt
+In lexicographical comparison: chrt before hrnec</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul><li> 7.24.4.3 The strcoll function (p: TBD) </li></ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.24.4.3 The strcoll function (p: TBD) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.24.4.3 The strcoll function (p: 366) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.21.4.3 The strcoll function (p: 329) </li></ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.11.4.3 The strcoll function </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="../wide/wcscoll" title="c/string/wide/wcscoll"> <span class="t-lines"><span>wcscoll</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> compares two wide strings in accordance to the current locale <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="strxfrm" title="c/string/byte/strxfrm"> <span class="t-lines"><span>strxfrm</span></span></a></div> </td> <td> transform a string so that strcmp would produce the same result as strcoll <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="../wide/wcsxfrm" title="c/string/wide/wcsxfrm"> <span class="t-lines"><span>wcsxfrm</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c95">(C95)</span></span></span></div> </td> <td> transform a wide string so that wcscmp would produce the same result as wcscoll <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="strcmp" title="c/string/byte/strcmp"> <span class="t-lines"><span>strcmp</span></span></a></div> </td> <td> compares two strings <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/string/byte/strcoll" title="cpp/string/byte/strcoll">C++ documentation</a></span> for <code>strcoll</code> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/string/byte/strcoll" class="_attribution-link">https://en.cppreference.com/w/c/string/byte/strcoll</a>
+ </p>
+</div>