By default, fish splits command substitutions (
(command)) on newlines. To override that behavior, you can use the special string subcommands like
string split (which allows you to define what to split on),
string split0 (which splits on NUL bytes) and
string collect (which doesn't split at all).
So the answer is:
set tst (cat file | string collect)
: Note that NUL bytes can't be passed to commands because unix passes the arguments as NUL-terminated strings, so there is no way for the command to know that the argument goes on, so
string collect effectively just captures the command output up to the first NUL, giving you at most one entry, while
string split0 might result in multiple arguments.