import mir.format: stringBuf; auto w = stringBuf; w.printEscaped("Hi \a\v\0\f\t\b \\\r\n" ~ `"@nogc"`); assert(w.data == `Hi \a\v\0\f\t\b \\\r\n\"@nogc\"`); w.reset; w.printEscaped("\x03"); assert(w.data == `\x03`);
See Implementation