| author | |
| committer | |
| log | c854c6577a0720fc538f55d9e2a65621172035eb |
| tree | 2cc2c336924fc7dfab788852ab1a22c13819d26e |
| parent | 9ef236bc114fa859768d0837abe4e7e573ad22c8 |
| parent | f6366f65bcff9405e11aeb6b876211f33c0076a4 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/363612 files changed, 4 insertions(+), 5 deletions(-)
lib/std/ascii.zig+3-3| ... | @@ -511,11 +511,11 @@ pub const HexEscape = struct { | ... | @@ -511,11 +511,11 @@ pub const HexEscape = struct { |
| 511 | }; | 511 | }; |
| 512 | 512 | ||
| 513 | /// Replaces non-ASCII bytes with hex escapes. | 513 | /// Replaces non-ASCII bytes with hex escapes. |
| 514 | pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) std.fmt.Alt(HexEscape, HexEscape.format) { | 514 | pub fn hexEscape(bytes: []const u8, case: std.fmt.Case) HexEscape { |
| 515 | return .{ .data = .{ .bytes = bytes, .charset = switch (case) { | 515 | return .{ .bytes = bytes, .charset = switch (case) { |
| 516 | .lower => HexEscape.lower_charset, | 516 | .lower => HexEscape.lower_charset, |
| 517 | .upper => HexEscape.upper_charset, | 517 | .upper => HexEscape.upper_charset, |
| 518 | } } }; | 518 | } }; |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | test hexEscape { | 521 | test hexEscape { |
lib/std/zig.zig+1-2| ... | @@ -545,8 +545,7 @@ pub fn stringEscape(bytes: []const u8, w: *Writer) Writer.Error!void { | ... | @@ -545,8 +545,7 @@ pub fn stringEscape(bytes: []const u8, w: *Writer) Writer.Error!void { |
| 545 | '\t' => try w.writeAll("\\t"), | 545 | '\t' => try w.writeAll("\\t"), |
| 546 | '\\' => try w.writeAll("\\\\"), | 546 | '\\' => try w.writeAll("\\\\"), |
| 547 | '"' => try w.writeAll("\\\""), | 547 | '"' => try w.writeAll("\\\""), |
| 548 | '\'' => try w.writeByte('\''), | 548 | ' ', '!', '#'...'[', ']'...'~' => try w.writeByte(byte), |
| 549 | ' ', '!', '#'...'&', '('...'[', ']'...'~' => try w.writeByte(byte), | ||
| 550 | else => { | 549 | else => { |
| 551 | try w.writeAll("\\x"); | 550 | try w.writeAll("\\x"); |
| 552 | try w.printInt(byte, 16, .lower, .{ .width = 2, .fill = '0' }); | 551 | try w.printInt(byte, 16, .lower, .{ .width = 2, .fill = '0' }); |