Hello, I’m just trying to understand what String.chunk does I am using the Elixir card decks from Clever Bunny and their String deck has this:

<<?a, ?b, 0xFFFF::utf16>>,

and that returns
[“ab”, <<255, 255>>]

Where are the 255’s coming from?

The code you’ve posted has returns another result

iex(4)> String.chunk(<<?a, ?b, 0xFFF::utf16>>, :valid)
[<<97, 98, 15>>, <<255>>]

I guess it simply misses one F and it should be

iex(10)> String.chunk(<<?a, ?b, 0xFFFF::utf16>>, :valid)
["ab", <<255, 255>>]

Oh sorry that was just a typo! I’ll fix it. What I don’t understand is how 255 is returned?

The code above is another way to write:

String.chunk(<<?a, ?b, 255, 255>>, :valid)

255 in decimal is FF in base-16.


Okay. That makes sense. Thank you.