I understand that \u
can help make unicode characters like "\u00E4"
becomes "ä"
.
How can I take a variable like "00E4"
and convert it to "ä"
? I cannot do "\u#{var}"
. I ithink first convert from hex to integer maybe?
iex(1)> a = 0x00E4
228
iex(2)> to_string([a])
"ä"
I hope this could help.
Edit:
iex(1)> a = "00E4"
iex(2)> int = String.to_integer(a, 16)
228
iex(3)> to_string([int])
"ä"
7 Likes
another way to look at it:
iex> <<0x00E4::utf8>>
"ä"
5 Likes