Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5953755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:52:17+00:00 2026-05-22T17:52:17+00:00

I have a binary <<a,b,c>> and I would like to extract the information from

  • 0

I have a binary <<"a,b,c">> and I would like to extract the information from this binary.

So I would like to have something like A=a, B=b and so on.
I need a general approach on this because the binary string always changes.

So it could be <<"aaa","bbb","ccc">>…

I tried to generate a list

erlang:binary_to_list(<<"a","b","c">>) 

but I get string as a result.

"abc"

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:52:18+00:00Added an answer on May 22, 2026 at 5:52 pm

    You did use the right method.

    binary_to_list(Binary) -> [char()]

    Returns a list of integers which correspond to the bytes of Binary.

    There is no string type in Erlang: http://www.erlang.org/doc/reference_manual/data_types.html#id63119. The console just displays the lists in string representation as a courtesy, if all elements are in printable ASCII range.

    You should read Erlang’s “Bit Syntax Expressions” documentation to understand how to work on binaries.

    Do not convert the whole binary into a list if you don’t need it in list representation!

    To extract the first three bytes you could use

    <<A, B, C, Rest/binary>> = <<"aaa","bbb","ccc">>.
    

    If you want to iterate over the binary data, you can use binary comprehension.

    << <<(F(X))>> || <<X>> <= <<"aaa","bbb","ccc">> >>.
    

    Pattern matching is possible, too:

    test(<<A, Tail/binary>>, Accu) -> test(Tail, Accu+A);
    test(_, Accu) -> Accu.
    
    882 = test(<<"aaa","bbb","ccc">>, 0).
    

    Even for reading one UTF-8 character at once. So to convert a binary UTF-8 string into Erlang’s “list of codepoints” format, you could use:

    test(<<A/utf8, Tail/binary>>, Accu) -> test(Tail, [A|Accu]);
    test(_, Accu) -> lists:reverse(Accu).
    
    [97,97,97,600,99,99,99] = test(<<"aaa", 16#0258/utf8, "ccc">>, "").
    

    (Note that `<<"aaa","bbb","ccc">> = <<"aaabbbccc">>. Don’t actually use the last code snipped but the linked method.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is going to be a long post. I would like to have suggestions
I have a lot of binary data on Core Data which I would like
I would like to delete parts from a binary file, using C++. The binary
If you have binary strings (literally String objects that contain only 1's and 0's),
I have a class that I need to binary serialize. The class contains one
I have a file that has both ASCII text and binary content. I would
Are there any utilities available that allow you to bulk extract binary data from
I have a task to import/transform and extract zipped binary files that contain both
I have a Windows Form project that I would like to migrate toward a
I would like to design webapps (eg. games) that have low latency. I presume

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.