DoxigAlpha

percentEncode

Function parameters

Parameters

#
w:*Writer
raw:[]const u8
isValidChar:fn (u8) bool

Type definitions in this namespace

Types

#

Returned value may point into `buffer` or be the original string.

Functions

#
getHost
Returned value may point into `buffer` or be the original string.
getHostAlloc
Returned value may point into `buffer` or be the original string.
percentDecodeBackwards
Percent decodes all %XX where XX is a valid hex number.
percentDecodeInPlace
Percent decodes all %XX where XX is a valid hex number.
parseAfterScheme
Parses the URI or returns an error.
parse
The return value will contain strings pointing into the original `text`.
resolveInPlace
Resolves a URI against a base URI, conforming to

Error sets in this namespace

Error Sets

#

= 255

Values

#

Source

Implementation

#
pub fn percentEncode(w: *Writer, raw: []const u8, comptime isValidChar: fn (u8) bool) Writer.Error!void {
    var start: usize = 0;
    for (raw, 0..) |char, index| {
        if (isValidChar(char)) continue;
        try w.print("{s}%{X:0>2}", .{ raw[start..index], char });
        start = index + 1;
    }
    try w.writeAll(raw[start..]);
}