summaryrefslogtreecommitdiff
path: root/src/utils.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-07-26 17:26:39 +0300
committerGravatar Uko Kokņevičs2024-07-26 17:26:39 +0300
commit00a07a4de190edfad5f16e22e238c4b5c37e2cba (patch)
tree39775a032e116ccdf2e0412bcf979dc773d330c4 /src/utils.zig
parentRespect request to wait on submitting requests (diff)
downloadukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.gz
ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.tar.xz
ukkobot-00a07a4de190edfad5f16e22e238c4b5c37e2cba.zip
Added msginfo command
Diffstat (limited to 'src/utils.zig')
-rw-r--r--src/utils.zig24
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 @@
1const std = @import("std");
2
3const Allocator = std.mem.Allocator;
4const ArrayList = std.ArrayList;
5
6pub fn escapeXml(writer: anytype, text: []const u8) !void {
7 for (text) |ch| {
8 try switch (ch) {
9 '<' => writer.writeAll("&lt;"),
10 '>' => writer.writeAll("&gt;"),
11 '&' => writer.writeAll("&amp;"),
12 '"' => writer.writeAll("&quot;"),
13 else => writer.writeByte(ch),
14 };
15 }
16}
17
18pub inline fn isNull(value: anytype) bool {
19 return switch (@typeInfo(@TypeOf(value))) {
20 .Null => true,
21 .Optional => value == null,
22 else => false,
23 };
24}