Thu, 23 Jan 2025 01:33:36 +0100
create new page structure
relates to #451
1141 | 1 | # string.h |
2 | ||
3 | UCX strings come in two variants: immutable (`cxstring`) and mutable (`cxmutstr`). | |
4 | The functions of UCX are designed to work with immutable strings by default but in situations where it is necessary, | |
5 | the API also provides alternative functions that work directly with mutable strings. | |
6 | Functions that change a string in-place are, of course, only accepting mutable strings. | |
7 | ||
8 | When you are using UCX functions, or defining your own functions, you are sometimes facing the "problem", | |
9 | that the function only accepts arguments of type `cxstring` but you only have a `cxmutstr` at hand. | |
10 | In this case you _should not_ introduce a wrapper function that accepts the `cxmutstr`, | |
11 | but instead you should use the `cx_strcast()` function to cast the argument to the correct type. | |
12 | ||
13 | In general, UCX strings are **not** necessarily zero-terminated. If a function guarantees to return zero-terminated | |
14 | string, it is explicitly mentioned in the documentation of the respective function. | |
15 | As a rule of thumb, you _should not_ pass the strings of a UCX string structure to another API without explicitly | |
16 | ensuring that the string is zero-terminated. |