fromHexString
lib.trivial.fromHexString
Docs pulled from | This Revision | about 1 hour ago
Convert a hexadecimal string to it's integer representation.
Type
fromHexString :: String -> [ String ]
Examples
fromHexString "FF"
=> 255
fromHexString "0x7fffffffffffffff"
=> 9223372036854775807
Noogle detected
Implementation
The following is the current implementation of this function.
fromHexString =
str:
let
match = builtins.match "(0x)?([0-7]?[0-9A-Fa-f]{1,15})" str;
in
if match != null then
(fromTOML "v=0x${builtins.elemAt match 1}").v
else
# TODO: Turn this into a `throw` in 26.05.
assert lib.warn "fromHexString: ${
lib.generators.toPretty { } str
} is not a valid input and will be rejected in 26.05" true;
let
noPrefix = lib.strings.removePrefix "0x" (lib.strings.toLower str);
in
(fromTOML "v=0x${noPrefix}").v;