with import ; let # toHex :: Word4 -> String toHex = elemAt (stringToCharacters "0123456789abcdef"); bytes = builtins.readFile ./bytes; # Mapping from bytes to their values mapping = listToAttrs (map (number: { name = substring (number - 1) 1 bytes; value = number; }) (range 1 255)); mapping' = listToAttrs (map (number: { name = byteToHex number; value = substring (number - 1) 1 bytes; }) (range 1 255)); # Convert a single character to its byte value asByte = char: mapping.${char}; # Convert a string to a list of byte values asBytes = str: map asByte (stringToCharacters str); # byteToHex :: Word8 -> String byteToHex = byte: toHex (byte / 16) + toHex (mod byte 16); encodeSSID = str: concatMapStrings byteToHex (asBytes str); string = "This is Unicode! 𐑯𐌍𐒘𐀰"; in asBytes string