Reputation: 407
I have the following value in Elixir:
<<140, 143, 153, 192, 237, 255, 10>>
Binaries don't seem to be enumerable. I need to convert it to a list so I can iterate over it, byte-by-byte, something like:
[140, 143, 153, 192, 237, 255, 10]
. I understand that to_char_array would do it if all the bytes were valid unicode characters but they aren't.
Just getting started with Elixir and really appreciate any suggestions for converting binaries to lists(byte arrays).
Upvotes: 10
Views: 7942
Reputation: 266
Have a look at erlang's bin_to_list/1
:binary.bin_to_list(<<140, 143, 153, 192, 237, 255, 10>>)
# [140, 143, 153, 192, 237, 255, 10]
Upvotes: 23