| 82 bool cx_strcaseprefix(cxstring string, cxstring prefix); |
82 bool cx_strcaseprefix(cxstring string, cxstring prefix); |
| 83 |
83 |
| 84 bool cx_strcasesuffix(cxstring string, cxstring suffix); |
84 bool cx_strcasesuffix(cxstring string, cxstring suffix); |
| 85 ``` |
85 ``` |
| 86 |
86 |
| 87 > Documentation work in progress. |
87 The `cx_strcmp()` function compares two UCX strings lexicographically |
| 88 >{style="warning"} |
88 and returns an integer greater than, equal to, or less than 0, if `s1` is greater than, equal to, or less than `s2`, respectively. |
| |
89 The `cx_strcmp_p()` function is equivalent, except that it takes pointers to the UCX strings and the signature is compatible with `cx_compare_func`. |
| |
90 |
| |
91 The functions `cx_strprefix()` and `cx_strsuffic()` check if `string` starts with `prefix` or ends with `suffix`, respectively. |
| |
92 |
| |
93 The functions `cx_strcasecmp()`, `cx_strcasecmp_p()`, `cx_strcaseprefix()`, and `cx_strcasesuffix()` are equivalent, |
| |
94 except that they compare the strings case-insensitive. |
| |
95 |
| |
96 > In the current version of UCX, case-insensitive comparisons are only guaranteed to work with ASCII characters. |
| |
97 {style="note"} |
| 89 |
98 |
| 90 ## Concatenation |
99 ## Concatenation |
| 91 |
100 |
| 92 ```C |
101 ```C |
| 93 #include <cx/string.h> |
102 #include <cx/string.h> |
| 102 cxmutstr str, size_t count, ... ); |
111 cxmutstr str, size_t count, ... ); |
| 103 |
112 |
| 104 size_t cx_strlen(size_t count, ...); |
113 size_t cx_strlen(size_t count, ...); |
| 105 ``` |
114 ``` |
| 106 |
115 |
| 107 > Documentation work in progress. |
116 The `cx_strcat_a()` function takes `count` UCX strings, |
| 108 >{style="warning"} |
117 allocates memory for a concatenation of those strings _with a single allocation_, |
| |
118 and copies the contents of the strings to the new memory. |
| |
119 `cx_strcat()` is equivalent, except that is uses the default stdlib allocator. |
| |
120 |
| |
121 The `cx_strcat_ma()` and `cx_strcat_m()` append the `count` strings to the specified string `str` and, |
| |
122 instead of allocating new memory, reallocate the existing memory in `str`. |
| |
123 If the pointer in `str` is `NULL`, there is no difference to `cx_strcat_a()`. |
| |
124 Note, that `count` always denotes the number of variadic arguments in _both_ variants. |
| |
125 |
| |
126 The function `cx_strlen()` sums the length of the specified strings. |
| |
127 |
| |
128 > There is no reason to use `cx_strlen()` for a single UCX string. |
| |
129 > Just access the `length` field of the structure directly. |
| |
130 |
| |
131 > You can mix `cxstring` and `cxmutstr` in the variadic arguments without the need of `cx_strcast()`. |
| 109 |
132 |
| 110 ## Find Characters and Substrings |
133 ## Find Characters and Substrings |
| 111 |
134 |
| 112 ```C |
135 ```C |
| 113 #include <cx/string.h> |
136 #include <cx/string.h> |