Function hexEscape [src]

Replaces non-ASCII bytes with hex escapes.

Prototype

pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Alt(HexEscape, HexEscape.format)

Parameters

bytes: []const u8case: std.fmt.Case

Example

test hexEscape { try std.testing.expectFmt("abc 123", "{f}", .{hexEscape("abc 123", .lower)}); try std.testing.expectFmt("ab\\xffc", "{f}", .{hexEscape("ab\xffc", .lower)}); try std.testing.expectFmt("abc 123", "{f}", .{hexEscape("abc 123", .upper)}); try std.testing.expectFmt("ab\\xFFc", "{f}", .{hexEscape("ab\xffc", .upper)}); }

Source

pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Alt(HexEscape, HexEscape.format) { return .{ .data = .{ .bytes = bytes, .charset = switch (case) { .lower => HexEscape.lower_charset, .upper => HexEscape.upper_charset, } } }; }