zeroclickinfo-goodies/lib/DDG/Goodie/Ascii.pm

35 lines
817 B
Perl
Raw Normal View History

2012-03-30 09:30:25 -07:00
package DDG::Goodie::Ascii;
# ABSTRACT: ASCII
2012-03-30 09:30:25 -07:00
use strict;
2012-03-30 09:30:25 -07:00
use DDG::Goodie;
triggers end => "ascii";
2012-11-06 16:06:29 -08:00
primary_example_queries '0110100001100101011011000110110001101111 to ascii';
description 'convert binary data to readable characters';
name 'Ascii';
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Binary.pm';
category 'transformations';
topics 'cryptography';
2012-03-30 09:30:25 -07:00
zci answer_type => "ascii_conversion";
2014-10-05 23:37:14 -07:00
zci is_cached => 1;
2012-03-30 09:30:25 -07:00
handle remainder => sub {
2014-10-28 11:36:15 -07:00
my $ascii = pack("B*", $1) if /^(([0-1]{8})*)\s+(in|to)$/;
2014-10-05 23:37:14 -07:00
my $binary = $1;
return unless $ascii;
return "$binary in binary is \"$ascii\" in ASCII",
structured_answer => {
input => [$binary],
operation => 'Binary to ASCII',
2014-10-05 23:37:14 -07:00
result => html_enc($ascii),
};
2012-04-12 19:46:59 -07:00
};
1;
2012-03-30 09:30:25 -07:00