binary to string

Kent Boortz <>
Sat Dec 28 19:13:50 CET 2002

"Inswitch Solutions - Erlang Evaluation" <> writes:
> I'm need convert binary to string, but I don't want use
> list_to_atom(binary_to_list(Bin)) because the atom it's not garbage
> collector.  It is possible to do this?

In Erlang strings are lists of integers so converting a binary
to a string (given that the binary is something that you can view
as a string) is just


Strings are not an efficient data type in Erlang but for most
applications they work ok. These are all the same "string" only
written differently

  [$f, $o, $o]
  [$f, $o, $o | [] ]
  [$f, $o | [$o | [] ]]
  [$f | [$o | [$o | [] ]]]

and takes 24 bytes on the heap on a 32 bit machine,


More information about the erlang-questions mailing list