diff options
| author | 2024-07-20 17:22:25 +0300 | |
|---|---|---|
| committer | 2024-07-20 17:22:25 +0300 | |
| commit | c70ffd095a6de5cd5b872796a0d82a8c5afc1511 (patch) | |
| tree | 56183274b05a294e357bad4d06b523472a1c4a4a /src/textutils.zig | |
| download | ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.tar.gz ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.tar.xz ukkobot-c70ffd095a6de5cd5b872796a0d82a8c5afc1511.zip | |
Initial commit
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 | } | ||