summaryrefslogtreecommitdiff
path: root/src/textutils.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/textutils.zig')
-rw-r--r--src/textutils.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/textutils.zig b/src/textutils.zig
new file mode 100644
index 0000000..41dd5f5
--- /dev/null
+++ b/src/textutils.zig
@@ -0,0 +1,16 @@
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}