diff --git a/src/lib.zig b/src/lib.zig index 3a98abdbec43d48c087b258d5123a17cd16f5cd4..e9b876240919d39b0ce5dd3ae5a2e7853d8161a4 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -1,5 +1,6 @@ const std = @import("std"); const string = []const u8; +const range = @import("range").range; pub fn fmtByteCountIEC(alloc: *std.mem.Allocator, b: u64) !string { return try reduceNumber(alloc, b, 1024, "B", "KMGTPEZY"); @@ -54,3 +55,11 @@ pub fn base64EncodeAlloc(alloc: *std.mem.Allocator, input: string) !string { var buf = try alloc.alloc(u8, base64.calcSize(input.len)); return base64.encode(buf, input); } + +pub fn asciiUpper(alloc: *std.mem.Allocator, input: string) !string { + var buf = try alloc.dupe(u8, input); + for (range(buf.len)) |_, i| { + buf[i] = std.ascii.toUpper(buf[i]); + } + return buf; +} diff --git a/zig.mod b/zig.mod index 596d8af23f1811b4bb24160ae8ac993efeba5fce..fa95ec6412cf26edc8776c8b1d30c79928e4f1cb 100644 --- a/zig.mod +++ b/zig.mod @@ -4,3 +4,4 @@ main: src/lib.zig license: MIT description: An assortment of random utility functions that aren't in std and don't deserve their own pacakge. dependencies: + - src: git https://github.com/nektro/zig-range