diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 12:18:29 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-07 14:05:26 -0700 |
commit | 2b9473f5e8816eeea76b2fdada184532be00d3a2 (patch) | |
tree | 387757b00f02521d1b3824a0e92f7778dbd32440 /internal/jsonparse/hex.go | |
parent | eab38672b2467810592b61fe5b0067086d3cbd2c (diff) |
internal: Split in to sub-packages
Diffstat (limited to 'internal/jsonparse/hex.go')
-rw-r--r-- | internal/jsonparse/hex.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/jsonparse/hex.go b/internal/jsonparse/hex.go new file mode 100644 index 0000000..3ed5f01 --- /dev/null +++ b/internal/jsonparse/hex.go @@ -0,0 +1,20 @@ +// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> +// +// SPDX-License-Identifier: GPL-2.0-or-later + +package jsonparse + +const Hex = "0123456789abcdef" + +func HexToInt(c rune) (byte, bool) { + switch { + case '0' <= c && c <= '9': + return byte(c) - '0', true + case 'a' <= c && c <= 'f': + return byte(c) - 'a' + 10, true + case 'A' <= c && c <= 'F': + return byte(c) - 'A' + 10, true + default: + return 0, false + } +} |