DoxigAlpha

writeHex

Writes an integer as base 16 to buf, right-aligned, assuming the buffer has already been filled with zeroes.

Function parameters

Parameters

#
buf:[]u8
x:usize

Type definitions in this namespace

Types

#
Method
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
Status
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
TransferEncoding
compression is intentionally omitted here since it is handled in `ContentEncoding`.
BodyWriter
Request or response body.

Source

Implementation

#
fn writeHex(buf: []u8, x: usize) void {
    assert(std.mem.allEqual(u8, buf, '0'));
    const base = 16;
    var index: usize = buf.len;
    var a = x;
    while (a > 0) {
        const digit = a % base;
        index -= 1;
        buf[index] = std.fmt.digitToChar(@intCast(digit), .lower);
        a /= base;
    }
}