2012-03-30 09:30:25 -07:00
|
|
|
package DDG::Goodie::Ascii;
|
2012-05-23 19:05:08 -07:00
|
|
|
# ABSTRACT: ASCII
|
2012-03-30 09:30:25 -07:00
|
|
|
|
2015-02-22 12:09:29 -08:00
|
|
|
use strict;
|
2012-03-30 09:30:25 -07:00
|
|
|
use DDG::Goodie;
|
|
|
|
|
2012-05-23 19:05:08 -07:00
|
|
|
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],
|
2015-01-08 23:52:22 -08:00
|
|
|
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
|
|
|
|