make oids module better (#16704)

* make oids modules better

* Update lib/pure/oids.nim

* fix
This commit is contained in:
flywind 2021-01-25 00:39:25 -06:00 • committed by GitHub
commit 8d3e0c7b9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 26 deletions

View file

@ -21,6 +21,13 @@ proc handleHexChar*(c: char, x: var int): bool {.inline.} =
else:
result = false
proc handleHexChar*(c: char): int {.inline.} =
case c
of '0'..'9': result = (ord(c) - ord('0'))
of 'a'..'f': result = (ord(c) - ord('a') + 10)
of 'A'..'F': result = (ord(c) - ord('A') + 10)
else: discard
proc decodePercent*(s: openArray[char], i: var int): char =
## Converts `%xx` hexadecimal to the character with ordinal number `xx`.
##