Helper functions for creating lists of bytes.
Basics.Int
Total number of bytes
fromInt : ByteCount -> Basics.Int -> List Basics.Int
Split an integer value into a list of bytes with the given length.
import Word.Hex as Hex
fromInt 4 0 |> Hex.fromByteList
--> "00000000"
fromInt 4 1 |> Hex.fromByteList
--> "00000001"
fromInt 2 2 |> Hex.fromByteList
--> "0002"
fromInt 1 255 |> Hex.fromByteList
--> "ff"
fromInt 4 256 |> Hex.fromByteList
--> "00000100"
fromInt 4 65537 |> Hex.fromByteList
--> "00010001"
fromInt 4 16777216 |> Hex.fromByteList
--> "01000000"
fromInt 8 344 |> Hex.fromByteList
--> "0000000000000158"
fromInt 16 344 |> Hex.fromByteList
--> "00000000000000000000000000000158"
fromUTF8 : String -> List Basics.Int
Convert a character into a list of bytes
import Word.Hex as Hex
fromUTF8 "a" |> Hex.fromByteList
--> "61"
fromUTF8 "I ❤ cheese"
--> [ 73, 32,
--> 226, 157, 164,
--> 32, 99, 104, 101, 101, 115, 101 ]
fromUTF8 "dѐf"
--> [ 100, 209, 144, 102 ]