I have an Erlang list of symbols: [104, 105, 106, 107 ...]
. How can I get a string from this list: "hijk..."
?
Asked
Active
Viewed 264 times
2
-
See also http://stackoverflow.com/questions/7371955/erlang-lists-with-single-numbers-over-8 for the opposite problem :) – legoscia Apr 24 '12 at 13:06
1 Answers
5
Strings as a datatype do not exist in Erlang. Stings are simply lists of characters.
[104, 105, 106, 107]
and "hijk"
are perfectly equivalent.
In fact, if you type the original list in the shell you get back the "string":
1> [104, 105, 106, 107].
"hijk"

Roberto Aloi
- 30,570
- 21
- 75
- 112
-
If you have at least one non-printable character in the list, the list will be printed as numbers – Isac Apr 23 '12 at 13:47