cstr
stdlib/cstr.tur
byte primitives on raw :cstr values.
Since: 2026-07-01
defn
cstr-len
(cstr-len [s : cstr] :)
byte length of a NUL-terminated C string.
Parameters
| s | NUL-terminated C string pointer |
Returns
Length in bytes, excluding the trailing NUL.
Example
(cstr-len "hello") ; => 5
defn
cstr-nth
(cstr-nth [s : cstr i : int] :)
byte at index i in a NUL-terminated C string.
Parameters
| s | NUL-terminated C string pointer | |
| i | zero-based byte index; caller must ensure 0 <= i < (cstr-len s) |
Returns
The unsigned byte value at position i.
Example
(cstr-nth "1+2" 1) ; => 43 ('+')