[erlang-questions] string in << >>

Gleb Peregud <>
Thu Dec 3 11:16:53 CET 2009


You have to convert your list to binary first:

1> X = "milsze-slowo-niz-dupa".
"milsze-slowo-niz-dupa"
2> Y = list_to_binary(X).
<<"milsze-slowo-niz-dupa">>
3> <<Y/binary, 3:2>>.
<<109,105,108,115,122,101,45,115,108,111,119,111,45,110,
  105,122,45,100,117,112,97,3:2>>

2009/12/3 Jakub Zawierucha <>:
> Hello,
>
> How can I put string into binary form ? Below you can find description on my
> problem.
>
> 49> f().
> ok
> 50> X = "dupa".
> "dupa"
> 51> <<"dupa", 3:2>>.
> <<100,117,112,97,3:2>>
> 52> <<X, 3:2>>.
> ** exception error: bad argument
>
> Thanks,
> Jakub Zawierucha
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>


More information about the erlang-questions mailing list