Capturing UTF-8 code point, then concatenate the corresponding character; covert code point to utf-8 binary?

I think I’ve been staring at pattern matches so long I’ve started to go blind. What I’d like to do is to inspect the code point for a character and then concatenate the character onto an accumulator.

iex> acc = ""
iex> <<x::utf8, rest::binary>> = "über"
iex> x
252  # <-- the code point
iex> acc <> <<x>>  # <-- how to concatenate the ü ?
iex> acc == "ü"
false   # nope.

It’s like I need the opposite of the ? where I can convert a code point into a binary. Can someone illuminate me while I soak my head in coffee? Thanks!

1 Like

This works, but I’m wondering if there’s a better way?

iex> acc <> to_string([x])
iex(1)> acc = ""
iex(2)> <<x::utf8, rest::binary>> = "über"
iex(3)>  x
iex(4)> acc = acc <> <<x::utf8>>
iex(5)> acc == "ü"