Function init [src]
cmd_line_w must be a WTF16-LE-encoded string.
The iterator stores and uses cmd_line_w, so its memory must be valid for
at least as long as the returned ArgIteratorWindows.
Prototype
pub fn init(allocator: Allocator, cmd_line_w: []const u16) InitError!ArgIteratorWindows
Parameters
allocator: Allocator
cmd_line_w: []const u16
Possible Errors
Source
pub fn init(allocator: Allocator, cmd_line_w: []const u16) InitError!ArgIteratorWindows {
const wtf8_len = unicode.calcWtf8Len(cmd_line_w);
// This buffer must be large enough to contain contiguous NUL-terminated slices
// of each argument.
// - During parsing, the length of a parsed argument will always be equal to
// to less than its unparsed length
// - The first argument needs one extra byte of space allocated for its NUL
// terminator, but for each subsequent argument the necessary whitespace
// between arguments guarantees room for their NUL terminator(s).
const buffer = try allocator.alloc(u8, wtf8_len + 1);
errdefer allocator.free(buffer);
return .{
.allocator = allocator,
.cmd_line = cmd_line_w,
.buffer = buffer,
};
}