docs/Writerside/topics/string.h.md

branch
docs/3.1
changeset 1141
a06a2d27c043
child 1142
9437530176bc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/Writerside/topics/string.h.md	Thu Jan 23 01:33:36 2025 +0100
@@ -0,0 +1,16 @@
+# string.h
+
+UCX strings come in two variants: immutable (`cxstring`) and mutable (`cxmutstr`).
+The functions of UCX are designed to work with immutable strings by default but in situations where it is necessary,
+the API also provides alternative functions that work directly with mutable strings.
+Functions that change a string in-place are, of course, only accepting mutable strings.
+
+When you are using UCX functions, or defining your own functions, you are sometimes facing the "problem",
+that the function only accepts arguments of type `cxstring` but you only have a `cxmutstr` at hand.
+In this case you _should not_ introduce a wrapper function that accepts the `cxmutstr`,
+but instead you should use the `cx_strcast()` function to cast the argument to the correct type.
+
+In general, UCX strings are **not** necessarily zero-terminated. If a function guarantees to return zero-terminated
+string, it is explicitly mentioned in the documentation of the respective function.
+As a rule of thumb, you _should not_ pass the strings of a UCX string structure to another API without explicitly
+ensuring that the string is zero-terminated.

mercurial