Function newbase60::sxg_to_num
source · pub fn sxg_to_num(s: &str) -> Option<u128>
Expand description
Convert a string into its New Base 60 representation, dropping invalid characters.
Valid New Base 60 characters are alphanumeric or underscores (that is, they
individually match the regex [a-zA-Z0-9_]
). Invalid characters will be treated as if
they did not exist. Empty strings will evaluate to 0.
If the resulting value is larger than 2128, then this function will return None
.
For more information, see this link.
Examples
use newbase60::sxg_to_num;
assert_eq!(sxg_to_num("NH"), Some(1337));
assert_eq!(sxg_to_num("N🥺H"), Some(1337));
assert_eq!(sxg_to_num("verylongstringthatoverflowsthemultiplicationbuffer"), None);