The q* stdlib docs
qstring: string operations
qstring exposes the string.* built-ins: case conversion, trimming, reversal, and a character count. They take the string as the first positional argument and return either a string or an integer under the result key. A useful convenience is implicit numeric coercion — if you pass a number where a string is expected, it is stringified first, so string.upper(7) and string.len(123) just work.
What it gives you#
qstring registers five public built-ins, all following the shared DMS convention and callable inline from QQL.
| Function | Returns | Behavior |
|---|---|---|
| string.upper | Str | Uppercases the input (Unicode-aware to_uppercase). |
| string.lower | Str | Lowercases the input (Unicode-aware to_lowercase). |
| string.trim | Str | Removes leading and trailing whitespace. |
| string.reverse | Str | Reverses the string by Unicode scalar (char) order. |
| string.len | Int | Character count — number of chars, not bytes. |
Input coercion#
The first positional argument is read as a string. A Str is used directly. An Int or Float is converted to its textual form first (for example 7 becomes "7", 1.5 becomes "1.5"). Any other type, or a missing argument, is treated as the empty string.
Resource budget#
These operations allocate proportionally to the input string: upper/lower/reverse/trim decode one copy and build another, and case folding can grow the string. Each string.* function declares a fixed 4096-byte (4 KB) memory budget and zero storage.
Example#
string.len returns the character count of its argument.
Request
string.len("hello")
# wire form:
{ "0": { "Str": "hello" } }Response
{ "result": { "Int": 5 } }Output
5Request
string.upper("ab")
string.reverse("abc")
string.upper(7)Response
{ "result": { "Str": "AB" } }
{ "result": { "Str": "cba" } }
{ "result": { "Str": "7" } }Output
AB
cba
7