Given a string such as "0110", how do I convert this to a bitstring containing the binary values represented by the string?
I checked the Base module, but it's based on RFC 4648 and is not designed for handling Base 2.
Copyright © 2021 Jogjafile Inc.
Here's one way:
Usage:
The benefit of doing it exhaustively using
caseand matching on binaries is two-fold:If you just want a quick hack, this works, but it will also happily convert nonsense like
"0140"too, so I think the first solution is better.