freeswitch/libs/xmlrpc-c/tools/binmode-rpc-kit/oct2bin

13 lines
235 B
Plaintext
Raw Normal View History

#!/usr/bin/perl
# Turn C-style octal escapes into binary.
# Call as "echo -n 'ab\0\001cd' | oct2bin > out.binmode".
binmode STDOUT;
while (<>) {
s/\\(\d\d\d)/chr(oct($1))/ge;
s/\\0/chr(0)/ge;
s/\\\\/\\/g;
print $_;
}