Skip to content

Commit

Permalink
UTF-8 decode the JSON data.
Browse files Browse the repository at this point in the history
Correctly displays package information from RPC when it contains unicode characters.

Example:

	trizen -Si wechat-uos
  • Loading branch information
trizen committed Feb 14, 2022
1 parent 3797386 commit 6efda76
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions trizen
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ sub error ($line) {

sub json2perl ($json) {
require JSON;
JSON::from_json($json);
JSON::from_json($json, {utf8 => 1});
}

sub start_sudo_autorepeat () {
Expand Down Expand Up @@ -2118,10 +2118,16 @@ sub search_packages (@keywords) {
}

my @aur_results;
foreach my $key (map { uri_escape_utf8($_) } grep { length() > 1 } @keywords) {
foreach my $key (map { uri_escape_utf8($_) } grep { length($_) > 1 } @keywords) {
push @aur_results, json2perl(get("$aur_rpc_base_url?v=$AUR_V&type=search&arg=$key") // next);
}

#<<<
#~ # Multiple keyword search with version 6.
#~ my $kw = uri_escape_utf8(join(' ', grep { length($_) > 1 } @keywords));
#~ my @aur_results = json2perl(get("$aur_rpc_base_url?v=6&type=search&arg=$kw") // '{}');
#>>>

my %seen;
my @keys_re = map { qr/\Q$_\E/i } @keywords;

Expand Down

0 comments on commit 6efda76

Please sign in to comment.