benchmark: generate more types of OSC sequences

This commit is contained in:
Jeffrey C. Ollie
2025-12-10 22:30:19 -06:00
parent 10bac6a5dd
commit cfdcd50e18
2 changed files with 136 additions and 0 deletions

View File

@@ -265,3 +265,16 @@ test "percent 7" {
@memcpy(&src, s);
try std.testing.expectError(error.DecodeError, urlPercentDecode(&src));
}
/// Is the given character valid in URI percent encoding?
fn isValidChar(c: u8) bool {
return switch (c) {
' ', ';', '=' => false,
else => return std.ascii.isPrint(c),
};
}
/// Write data to the writer after URI percent encoding.
pub fn urlPercentEncode(writer: *std.Io.Writer, data: []const u8) std.Io.Writer.Error!void {
try std.Uri.Component.percentEncode(writer, data, isValidChar);
}