in reply to Convert ASCII string to 7-bit binary string
Here's another regex-based solution:
$string = '4B'; ($out = $string) =~ s/(.)/unpack 'B8', $1/eg;
Fairly straightforward, actually - this globally (/g) matches every character ((.)), executes (/e) the embedded snippet of code, and replaces the matched character with the result of the call to unpack.
EDIT: please see below for a version that actually works properly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Convert ASCII string to 7-bit binary string
by Pascal666 (Scribe) on Oct 27, 2015 at 22:21 UTC | |
by AppleFritter (Vicar) on Oct 27, 2015 at 22:29 UTC | |
by ikegami (Patriarch) on Oct 28, 2015 at 21:22 UTC |