decoderWithIgnore
Creates a new decoder that ignores certain characters. The decoder will skip any characters that are in the ignore list. The ignore list must not contain any valid hexadecimal characters.
Function parameters
Parameters
- ignore_chars:[]const u8
(best-effort) constant time hexadecimal encoding and decoding.
Types
Error sets in this namespace
Error Sets
Source
Implementation
pub fn decoderWithIgnore(ignore_chars: []const u8) error{InvalidCharacter}!DecoderWithIgnore {
var ignored_chars = StaticBitSet(256).initEmpty();
for (ignore_chars) |c| {
switch (c) {
'0'...'9', 'a'...'f', 'A'...'F' => return error.InvalidCharacter,
else => if (ignored_chars.isSet(c)) return error.InvalidCharacter,
}
ignored_chars.set(c);
}
return DecoderWithIgnore{ .ignored_chars = ignored_chars };
}