Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########################################################################
- # Display each ctr in decimal ascii like: "(65 66 32 38)"
- # In: long string
- # Out: string(s) showing decimal value of each ctr.
- sub asciify
- {my($l)=@_;
- my($s,$t,@a,@b,$i,$j,$procname,$le);
- $procname="asciify";
- $le=len($l);
- if ($le==0)
- {
- return "(zero len)";
- }
- $s="(";
- for ($i=0; $i<=$le; $i++)
- {
- $t=substr($l,$i,1); # Get one ctr.
- $s.=ord($t)." "; # Add decimal value of ctr.
- } # for i
- $s=trim($s);
- $s.=")\n";
- $s.="(";
- for ($i=0; $i<=$le; $i++)
- {
- $t=substr($l,$i,1); # Get one ctr.
- if ($t=~m/[\t\l\r\x00\x01\x02]/) # Convert odd ctrs to space.
- {
- $t=" ";
- }
- $s.=" ".$t." "; # Add decimal value of ctr.
- } # for i
- $s=trim($s);
- $s.=")";
- return $s; # asciify
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement