diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index d1d38c24d..6c1d46722 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -542,13 +542,20 @@ pub const Surface = struct { // If we have an initial input then we set it. if (opts.initial_input) |c_input| { const alloc = config.arenaAlloc(); + + // We need to escape the string because the "raw" field + // expects a Zig string. + var buf: std.Io.Writer.Allocating = .init(alloc); + defer buf.deinit(); + try std.zig.stringEscape( + std.mem.sliceTo(c_input, 0), + &buf.writer, + ); + config.input.list.clearRetainingCapacity(); try config.input.list.append( alloc, - .{ .raw = try alloc.dupeZ(u8, std.mem.sliceTo( - c_input, - 0, - )) }, + .{ .raw = try buf.toOwnedSliceSentinel(0) }, ); }