| author | |
| committer | |
| log | aebddddaa1dd96e7a86f3ee10cb6c5e89b56d58b |
| tree | 9c9e24d88a606260ad11a4f2d384d8473755fa53 |
| parent | 02301520811d7796de6e4f87961a44a6f458f702 |
| signature |
2 files changed, 11 insertions(+), 0 deletions(-)
src/lib.zig+1| ... | ... | @@ -40,6 +40,7 @@ pub const isArrayOf = @import("./isArrayOf.zig").isArrayOf; |
| 40 | 40 | pub const parse_int = @import("./parse_int.zig").parse_int; |
| 41 | 41 | pub const parse_bool = @import("./parse_bool.zig").parse_bool; |
| 42 | 42 | pub const to_hex = @import("./to_hex.zig").to_hex; |
| 43 | pub const to_HEX = @import("./to_hex.zig").to_HEX; | |
| 43 | 44 | pub const FieldUnion = @import("./FieldUnion.zig").FieldUnion; |
| 44 | 45 | pub const LoggingReader = @import("./LoggingReader.zig").LoggingReader; |
| 45 | 46 | pub const LoggingWriter = @import("./LoggingWriter.zig").LoggingWriter; |
src/to_hex.zig+10| ... | ... | @@ -22,6 +22,16 @@ pub fn to_hex(array: anytype) [array.len * 2]u8 { |
| 22 | 22 | return res; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | pub fn to_HEX(array: anytype) [array.len * 2]u8 { | |
| 26 | var res: [array.len * 2]u8 = undefined; | |
| 27 | for (&array, 0..) |x, i| res[i * 2 ..][0..2].* = alphabet[@as(usize, x) * 2 ..][0..2].*; | |
| 28 | for (&res) |*x| x.* = std.ascii.toUpper(x.*); | |
| 29 | return res; | |
| 30 | } | |
| 31 | ||
| 25 | 32 | test { |
| 26 | 33 | try std.testing.expect(std.mem.eql(u8, &to_hex(rawIntBytes(u64, 0x4e5a7da9f3f1d132)), "4e5a7da9f3f1d132")); |
| 27 | 34 | } |
| 35 | test { | |
| 36 | try std.testing.expect(std.mem.eql(u8, &to_hex(rawIntBytes(u64, 0x4e5a7da9f3f1d132)), "4E5A7dA9F3F1D132")); | |
| 37 | } |