← all modules
module

stdlib::hex

defined in C:\Users\bye45\.glide\bin/src/stdlib/hex.glide

Lowercase hex of every byte. Two hex digits per input byte.

fn fn hex_encode(s: string) -> string

Lowercase hex of every byte. Two hex digits per input byte.

glide
hex_encode("ABC");    // "414243"

hex_encode("");       // ""
fn fn hex_decode(s: string) -> !string

Inverse of hex_encode. Accepts upper- and lower-case digits; both "414243" and "414243".to_upper() round-trip the same. Rejects odd-length input or non-hex bytes with err.

glide
let r: !string = hex_decode("414243");
if r.ok { println!(r.val); }      // "ABC"


let bad: !string = hex_decode("xy");
if !bad.ok { println!(bad.err); } // "non-hex char"