Zig Requires Chilkat v11.1.0+
Zig
HTML Entity Encode and Decode in StringBuilder
Demonstrates HTML encoding and decoding the contents of a StringBuilder.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const sb = try chilkat.StringBuilder.init();
defer sb.deinit();
const s = "< é ü ç Ω Hello & World ✓ >";
sb.append(s) catch {};
sb.encode("html", "utf-8") catch {};
std.debug.print("{s}\n", .{try sb.getAsString(alloc)});
// Output:
// < é ü ç Ω Hello & World ✓ >
// To decode:
sb.decode("html", "utf-8") catch {};
std.debug.print("{s}\n", .{try sb.getAsString(alloc)});
// Output:
// < é ü ç Ω Hello & World ✓ >
}