In Erlang how do I convert a String to a binary value?

erlang

Solution

In Erlang strings are represented as a list of integers. You can therefore use the `list_to_binary` (built-in-function, aka BIF). Here is an example I ran in the Erlang console (started with `erl`):

1> list_to_binary("hello world").
<<"hello world">>

Problem

In Erlang how do I convert a `string` to a `binary` value? ``` String = "Hello" %% should be Binary = <<"Hello">> ```

Original source