By applying the $ (cast) operator while passing ` (the null symbol) as its left argument:

q)` $ “foo”

The cast operator also accepts an uppercase type character as its left argument:

q)”S” $ “foo”

Moreover, you can convert a list of strings at once:

q)”S” $ (“foo”; “bar”; “baz”)

To go the other way, use the string function:

q)string `foo

Since the string function is implemented as the monadic form (i.e., single argument overload) of the k function $


— it is also possible to write the above cast as follows:


Although we don’t recommend it, we thought you should know in case you see it in the wild.

See also: type

Short answer: “\001” sv (“one”; “two”; “three”)

To build delimited strings in general, use the sv (scalar from vector) function:

q)”, ” sv (“Hello”; “world!”)
“Hello, world!”

As in many programming languages, the syntax for non-printable ASCII characters is borrowed from C, although only a subset of C’s sequences is supported:

\n      newline
\r      carriage return
\t      tab

(q also supports a few printable escape sequences: \\, \” and \’). However, as in C, you can express any ASCII code in q by following a backslash with the code’s 3 digit octal representation:

q)”\054\040″ sv (“Hello”; “world!”)
“Hello, world!”

Since ctrl-A is ASCII 1, we need to use \001:

q)fstring: “\001” sv (“f1=va”; “f2=vb”; “f3=vc”)

We can use 0: to write fstring to a file, and use an external program to confirm the result:

q)`:test 0: enlist fstring
$ hexdump test
0000000 66 31 3d 76 61 01 66 32 3d 76 62 01 66 33 3d 76
0000010 63 0a

To break fstring up into its parts, see How do I parse a ctrl-A delimited string?