aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.erl
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2023-10-26 13:03:22 +0100
committerLouis Pilfold <louis@lpil.uk>2023-10-26 13:07:39 +0100
commite0cefe61b7519d8356885b941c34bbf4763cb71c (patch)
treec6dbff1309805ecb6f1b0d9df6cb091552ec6970 /src/gleam_stdlib.erl
parentd55bfcbfc6c6c836013e4b9b45eb70c729d5ca7b (diff)
downloadgleam_stdlib-e0cefe61b7519d8356885b941c34bbf4763cb71c.tar.gz
gleam_stdlib-e0cefe61b7519d8356885b941c34bbf4763cb71c.zip
Hex!
Diffstat (limited to 'src/gleam_stdlib.erl')
-rw-r--r--src/gleam_stdlib.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gleam_stdlib.erl b/src/gleam_stdlib.erl
index 0ac4747..0e2136f 100644
--- a/src/gleam_stdlib.erl
+++ b/src/gleam_stdlib.erl
@@ -13,7 +13,7 @@
decode_tuple5/1, decode_tuple6/1, tuple_get/2, classify_dynamic/1, print/1,
println/1, print_error/1, println_error/1, inspect/1, float_to_string/1,
int_from_base_string/2, utf_codepoint_list_to_string/1, contains_string/2,
- crop_string/2
+ crop_string/2, base16_decode/1
]).
%% Taken from OTP's uri_string module
@@ -490,3 +490,10 @@ crop_string(String, Prefix) ->
contains_string(String, Substring) ->
is_bitstring(string:find(String, Substring)).
+
+base16_decode(String) ->
+ try
+ {ok, binary:decode_hex(String)}
+ catch
+ _:_ -> {error, nil}
+ end.