blob: c6e85089c7e0fb1c01fa9ad825cd645e89144487 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
pub fn escapeXml(writer: anytype, text: []const u8) !void {
for (text) |ch| {
try switch (ch) {
'<' => writer.writeAll("<"),
'>' => writer.writeAll(">"),
'&' => writer.writeAll("&"),
'"' => writer.writeAll("""),
else => writer.writeByte(ch),
};
}
}
pub inline fn isNull(value: anytype) bool {
return switch (@typeInfo(@TypeOf(value))) {
.Null => true,
.Optional => value == null,
else => false,
};
}
|