MCPcopy Create free account
hub / github.com/buger/jsonparser / h2I

Function h2I

escape.go:60–71  ·  view source on GitHub ↗

reqproof:lemma h2I_range func(c byte) bool { r := h2I(c) return r == -1 || (r >= 0 && r <= 15) } reqproof:lemma h2I_decimal_digit func(c byte) bool { if c < '0' || c > '9' { return true } r := h2I(c) return r >= 0 && r <= 9 } reqproof:lemma h2I_uppercase_hex func(c byte) bool { if c < 'A' || c > 'F'

(c byte)

Source from the content-addressed store, hash-verified

58// return true
59// }
60func h2I(c byte) int {
61 if c >= 48 && c <= 57 { // '0'..'9'
62 return int(c - 48)
63 }
64 if c >= 65 && c <= 70 { // 'A'..'F'
65 return int(c-65) + 10
66 }
67 if c >= 97 && c <= 102 { // 'a'..'f'
68 return int(c-97) + 10
69 }
70 return badHex
71}
72
73// decodeSingleUnicodeEscape decodes a single \uXXXX escape sequence. The prefix \u is assumed to be present and
74// is not checked.

Callers 2

TestH2IFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestH2IFunction · 0.68