From 8896f4f1bb6126faad363d2d471b0fbd06dd6374 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 30 Dec 2019 19:32:58 -0800 Subject: [PATCH] GoogleSearch: fix versus mode and utf8 titles --- Plugins/GoogleSearch.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Plugins/GoogleSearch.pm b/Plugins/GoogleSearch.pm index c38c7eac..1d1a3540 100644 --- a/Plugins/GoogleSearch.pm +++ b/Plugins/GoogleSearch.pm @@ -9,6 +9,8 @@ package Plugins::GoogleSearch; use warnings; use strict; +use feature 'unicode_strings'; + use WWW::Google::CustomSearch; use HTML::Entities; @@ -80,7 +82,13 @@ sub googlesearch { return "$nick: No results for $b"; } - return "$nick: $a: (", $result1->formattedTotalResults, ") ", decode_entities $result1->items->[0]->title, " <", $result1->items->[0]->link, "> VS $b: (", $result2->formattedTotalResults, ") ", decode_entities $result2->items->[0]->title, " <", $result2->items->[0]->link, ">"; + my $title1 = $result1->items->[0]->title; + my $title2 = $result2->items->[0]->title; + + utf8::decode $title1; + utf8::decode $title2; + + return "$nick: $a: (" . $result1->formattedTotalResults . ") " . decode_entities($title1) . " <" . $result1->items->[0]->link . "> VS $b: (" . $result2->formattedTotalResults . ") " . decode_entities($title2) . " <" . $result2->items->[0]->link . ">"; } my $result = $engine->search($arguments); @@ -93,7 +101,9 @@ sub googlesearch { my $comma = ""; foreach my $item (@{$result->items}) { - $output .= $comma . decode_entities $item->title . ': <' . $item->link . ">"; + my $title = $item->title; + utf8::decode $title; + $output .= $comma . decode_entities($title) . ': <' . $item->link . ">"; $comma = " -- "; last if --$matches <= 0; }