In Erlang how do I convert a string
to a binary
value?
String = "Hello"
%% should be
Binary = <<"Hello">>
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">>