Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.1.0+

HTML Encoding

Demonstrates HTML encoding and decoding.

Chilkat Zig Downloads

Zig
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:
    // < &eacute; &uuml; &ccedil; &ohm; Hello & World &check; >

    // To decode:
    s = try crypt.decodeString(alloc, html_encoded, "utf-8", "html");
    std.debug.print("{s}\n", .{s});

    // Output:
    // < é ü ç Ω Hello & World ✓ >
}