Special Characters in Eixir

Hello there,

I have to write a file that has the special character " \x1f ", how can I concatenate with other strings programmatically in elixir.

Thanks in advance!

# All here are equivalent
a = "yourstring\x1f"
b = "yourstring" <> "\x1f"
c = "yourstring" <> <<31>>
4 Likes

In addition to what @Nicd said, if you are writing to file you can use IO lists. So:

# Assuming a, b, and c from @Nicd snippet
IO.write(a)
IO.write(b)
IO.write(c)

# Will be the same as

IO.write(["yourstring", "\x1f"])
IO.write(["yourstring" | "\x1f"])
IO.write(["yourstring", 31])
IO.write(["yourstring", [31]])
2 Likes