Bumping this excellent Noob question.
This is something confuses many new to Elixir. The
Inspect protocol for lists (which is what displays something in iex, defaults to a charlist if all the elements of the list are printable characters, including printable control characters like
\t \r \n, etc.
If you are working in iex, this can be a pain if you're looking at an integer list that just happens to have all printable characters. If you have this issue in iex, try using
i on the list, or add a non printing integer to the list as shown below.
iex(11)> 'test' ++ 
[116, 101, 115, 116, 0]
iex(8)> [9, 13, 48, 50]
iex(9)> i '\t\r02'
This is a list of integers that is printed as a sequence of characters
delimited by single quotes because all the integers in it represent valid
ASCII characters. Conventionally, such lists of integers are referred to as
"charlists" (more precisely, a charlist is a list of Unicode codepoints,
and ASCII is a subset of Unicode).
[9, 13, 48, 50]
IEx.Info, Inspect, String.Chars, List.Chars, Collectable, Enumerable
iex(10)> [0, 9, 13, 48, 50]
[0, 9, 13, 48, 50]
iex(13)> '\t\r02' == [9, 13, 48, 50]