diff options
Diffstat (limited to 'src/textutils.zig')
| -rw-r--r-- | src/textutils.zig | 16 |
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 @@ | |||
| 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 | } | ||