| author | |
| committer | |
| log | d14f97efa894ee732e2395b8c0ca101764b40587 |
| tree | 00b474773bf479eab7267d438e664aceff5bb903 |
| parent | a6e8db462de2eab7636ee26ed4c1f8b238c55f96 |
2 files changed, 18 insertions(+), 0 deletions(-)
src/asciiLower.zig created+17| ... | ... | @@ -0,0 +1,17 @@ |
| 1 | const std = @import("std"); | |
| 2 | const string = []const u8; | |
| 3 | const extras = @import("./lib.zig"); | |
| 4 | ||
| 5 | pub fn asciiLower(alloc: std.mem.Allocator, input: string) ![:0]u8 { | |
| 6 | var buf = try alloc.dupeZ(u8, input); | |
| 7 | for (input, 0..) |c, i| buf[i] = std.ascii.toLower(c); | |
| 8 | return buf; | |
| 9 | } | |
| 10 | ||
| 11 | pub fn asciiLowerComptime(comptime input: string) [:0]u8 { | |
| 12 | var buf: [input.len + 1]u8 = undefined; | |
| 13 | for (input, 0..) |c, i| buf[i] = std.ascii.toLower(c); | |
| 14 | buf[input.len] = 0; | |
| 15 | const result = buf[0..input.len :0]; | |
| 16 | return result; | |
| 17 | } |
src/lib.zig+1| ... | ... | @@ -117,3 +117,4 @@ pub usingnamespace @import("./ManyArrayList.zig"); |
| 117 | 117 | pub usingnamespace @import("./compareFnBasic.zig"); |
| 118 | 118 | pub usingnamespace @import("./compareFnField.zig"); |
| 119 | 119 | pub usingnamespace @import("./compareFnRange.zig"); |
| 120 | pub usingnamespace @import("./asciiLower.zig"); |