Process module

append_quoted

procedure · 1 overloadSource

Appends s to builder, in double quotes when it has to be: when it is empty or holds a space, a tab or a double quote. A quote inside is escaped with a backslash, and backslashes before a quote or before the closing quote are doubled, which are the rules of the Windows command line, so the program at the other end splits it back into the same text.

append_quoted :: (builder: *String_Builder, s: string)

Parameters

builder: *String_Builder
s: string
Example
builder: String_Builder;
append_quoted(*builder, "plain");
append(*builder, " ");
append_quoted(*builder, "two words");
append(*builder, " ");
append_quoted(*builder, "");
text := builder_to_string(*builder);
assert(text == "plain \"two words\" \"\"");
free(text);

Doesn't run in the browser (skipped on wasm).

See also