| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const string = []const u8; |
| 3 | const range = @import("range").range; |
| 3 | 4 | |
| 4 | 5 | pub fn fmtByteCountIEC(alloc: *std.mem.Allocator, b: u64) !string { |
| 5 | 6 | return try reduceNumber(alloc, b, 1024, "B", "KMGTPEZY"); |
| ... | ... | @@ -54,3 +55,11 @@ pub fn base64EncodeAlloc(alloc: *std.mem.Allocator, input: string) !string { |
| 54 | 55 | var buf = try alloc.alloc(u8, base64.calcSize(input.len)); |
| 55 | 56 | return base64.encode(buf, input); |
| 56 | 57 | } |
| 58 | |
| 59 | pub fn asciiUpper(alloc: *std.mem.Allocator, input: string) !string { |
| 60 | var buf = try alloc.dupe(u8, input); |
| 61 | for (range(buf.len)) |_, i| { |
| 62 | buf[i] = std.ascii.toUpper(buf[i]); |
| 63 | } |
| 64 | return buf; |
| 65 | } |