Zig Requires Chilkat v11.1.0+
Zig
HTML Encoding
Demonstrates HTML encoding and decoding.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 crypt = try chilkat.Crypt2.init();
defer crypt.deinit();
var s: [:0]const u8 = "< é ü ç Ω Hello & World ✓ >";
const html_encoded = try crypt.encodeString(alloc, s, "utf-8", "html");
std.debug.print("{s}\n", .{html_encoded});
// Output:
// < é ü ç Ω Hello & World ✓ >
// To decode:
s = try crypt.decodeString(alloc, html_encoded, "utf-8", "html");
std.debug.print("{s}\n", .{s});
// Output:
// < é ü ç Ω Hello & World ✓ >
}