diff options
| author | 2024-07-26 17:26:39 +0300 | |
|---|---|---|
| committer | 2024-07-26 17:26:39 +0300 | |
| commit | 00a07a4de190edfad5f16e22e238c4b5c37e2cba (patch) | |
| tree | 39775a032e116ccdf2e0412bcf979dc773d330c4 /src/utils.zig | |
| parent | Respect request to wait on submitting requests (diff) | |
| download | ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.gz ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.xz ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.zip | |
Added msginfo command
Diffstat (limited to 'src/utils.zig')
| -rw-r--r-- | src/utils.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils.zig b/src/utils.zig new file mode 100644 index 0000000..c6e8508 --- /dev/null +++ b/src/utils.zig | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | const Allocator = std.mem.Allocator; | ||
| 4 | const ArrayList = std.ArrayList; | ||
| 5 | |||
| 6 | pub fn escapeXml(writer: anytype, text: []const u8) !void { | ||
| 7 | for (text) |ch| { | ||
| 8 | try switch (ch) { | ||
| 9 | '<' => writer.writeAll("<"), | ||
| 10 | '>' => writer.writeAll(">"), | ||
| 11 | '&' => writer.writeAll("&"), | ||
| 12 | '"' => writer.writeAll("""), | ||
| 13 | else => writer.writeByte(ch), | ||
| 14 | }; | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | pub inline fn isNull(value: anytype) bool { | ||
| 19 | return switch (@typeInfo(@TypeOf(value))) { | ||
| 20 | .Null => true, | ||
| 21 | .Optional => value == null, | ||
| 22 | else => false, | ||
| 23 | }; | ||
| 24 | } | ||