Changeset 1530
- Timestamp:
- 08/20/06 21:27:36
- Files:
-
- trunk/plagger/bin/plagger-search (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/bin/plagger-search
r1391 r1530 3 3 use warnings; 4 4 5 use Encode ;5 use Encode (); 6 6 use FindBin; 7 7 use Getopt::Long; … … 15 15 16 16 my $context = Plagger->new(config => $path); 17 my $query = Encode::decode_utf8($ARGV[0]);17 my $query = decode($ARGV[0]); 18 18 19 19 my @feeds = $context->search($query); 20 20 21 21 my $feed = $feeds[0]; 22 binmode STDOUT, ":utf8"; 23 print "Search for '$query': ", $feed->count, " entries found.\n\n"; 22 binmode STDOUT, ":utf8" unless $context->conf->{log}->{encoding}; 23 exit unless $feed; 24 print "Search for '" . encode($query) . "': ", $feed->count , " entries found.\n\n"; 24 25 25 26 for my $entry ($feed->entries) { 26 print $entry->title, $entry->author ? "(by " . $entry->author. ")" : '', "\n";27 print $entry->body; # summary27 print encode($entry->title), $entry->author ? "(by " . encode($entry->author) . ")" : '', "\n"; 28 print encode($entry->body); # summary 28 29 print $entry->permalink, "\n"; 29 30 } 30 31 32 sub decode { 33 my $str = shift; 34 if ($context->conf->{log}->{encoding}) { 35 $str = Encode::decode($context->conf->{log}->{encoding}, $str); 36 } else { 37 $str = Encode::decode_utf8($str); 38 } 39 return $str; 40 } 41 42 sub encode { 43 my $str = shift; 44 if ($context->conf->{log}->{encoding}) { 45 $str = Encode::decode_utf8($str) unless utf8::is_utf8($str); 46 $str = Encode::encode($context->conf->{log}->{encoding}, $str); 47 } 48 return $str; 49 }
