percentDecodeBackwards
Percent decodes all %XX where XX is a valid hex number.
output may alias input if output.ptr <= input.ptr.
Mutates and returns a subslice of output.
Function parameters
Parameters
- output:[]u8
- input:[]const u8
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
- host_name_max
- = 255
Source
Implementation
pub fn percentDecodeBackwards(output: []u8, input: []const u8) []u8 {
var input_index = input.len;
var output_index = output.len;
while (input_index > 0) {
if (input_index >= 3) {
const maybe_percent_encoded = input[input_index - 3 ..][0..3];
if (maybe_percent_encoded[0] == '%') {
if (std.fmt.parseInt(u8, maybe_percent_encoded[1..], 16)) |percent_encoded_char| {
input_index -= maybe_percent_encoded.len;
output_index -= 1;
output[output_index] = percent_encoded_char;
continue;
} else |_| {}
}
}
input_index -= 1;
output_index -= 1;
output[output_index] = input[input_index];
}
return output[output_index..];
}