Take the 2-minute tour ×

I've stumbled on a quite irritating problem;

I'm trying to generate a binary of a string-list and back again. Eg

erlang:binary_to_list(erlang:list_to_binary(["hello", "world"])

This will return "helloworld" and not a list with two different elements. Does anyone have any ideas of how to solve this? One solution might be to encode every element, but there might be a more elegant solution for this?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

Yes, you have to encode it somehow. Here's the simplest way to do it by encoding it into Erlang binary term format

erlang:binary_to_term(erlang:term_to_binary(["hello", "world"]))
share|improve this answer
Ah. Why didn't I think of that. Thanks :) –  Burbas Aug 29 '10 at 19:28
add comment

Strings are merely a list of ints in erlang those the concat done by list_to_binary.

share|improve this answer
add comment

Your Answer


