Function charToDigit [src]

Prototype

pub fn charToDigit(c: u8, base: u8) (error{InvalidCharacter}!u8)

Parameters

c: u8base: u8

Source

pub fn charToDigit(c: u8, base: u8) (error{InvalidCharacter}!u8) { const value = switch (c) { '0'...'9' => c - '0', 'A'...'Z' => c - 'A' + 10, 'a'...'z' => c - 'a' + 10, else => return error.InvalidCharacter, }; if (value >= base) return error.InvalidCharacter; return value; }