[thelist] Binary
Andre Torrez
andre at torrez.org
Thu Mar 29 18:20:36 CST 2001
>I'm still waiting for this thread to be relevant to web development.
>
>Please, folks, keep it on topic.
I'll give it my best shot...
take this string:
10110.00111.01110.10110.01000.01011.01011.00110.10100.00000.10001.00011.10011.00111.00100.00110.10100.00000.10001.00011.10010
(all on one line!)
paste it into this form..
http://torrez.org/decode.html
and submit it.
Here's the perl source so you can learn about packing and unpacking (note,
I'm not really a Perl programmer, just another hacker):
#!/usr/bin/perl -w
use CGI;
$cgi = new CGI;
print "Content-type:text/html", "\n\n";
$to_decode = $cgi->param('decode');
@bits = split('\.', $to_decode);
print "<PRE>";
foreach $bit (@bits)
{
#pack these 'bits' into a binary string
$binary = pack("B8", "000$bit");
#convert this binary number to a decimal
$decimal = join('', unpack('C*', $binary));
#convert it to an ascii character
$character = chr(65+$decimal);
#print something tidy
printf "%8s -> %2s -> %1s\n", $bit, $decimal, $character;
}
print "</PRE>";
Anyway, I used to be on this list, and monkeyjunkies a long time ago. It's
nice to be back. I hope I can help out, and I hope people can help me.
-Andre Torrez
http://filepile.org/
More information about the thelist
mailing list