[erlang-questions] string to binary

Bob Ippolito bob@REDACTED
Wed Oct 19 13:06:38 CEST 2011


You'll want to use list_to_integer(X, 16) but otherwise that looks
correct. You could even use a binary comprehension:

<<<<(list_to_integer(X, 16))>> || X <-
string:tokens("00:11:22:33:44:55", ":")>>.

On Wed, Oct 19, 2011 at 3:12 AM, Chandru
<chandrashekhar.mullaparthi@REDACTED> wrote:
> Here is one solution.
>
> list_to_binary([list_to_integer(X) || X <-
> string:tokens("00:11:22:33:44:55", ":")]).
>
> cheers
> Chandru
>
> On 19 October 2011 00:02, Wes James <comptekki@REDACTED> wrote:
>>
>> Is there a way to get "00:11:22:33:44:55" in to this format
>> <<16#00,16#11,16#22,16#33,16#44,16#55>>?
>>
>> I can do string:tokens(S) to split the string (list) up, but how do
>> you put back in <<16#....>>  format?
>>
>> thanks,
>>
>> -wes
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list