mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 10:34:52 +01:00
Fix some UTF8 <=> JSON encoding issues?
This commit is contained in:
parent
8d560ef988
commit
7b142c68f5
@ -374,6 +374,10 @@ sub find_factoid {
|
||||
sub escape_json {
|
||||
my ($self, $text) = @_;
|
||||
my $thing = {thing => $text};
|
||||
# not sure why we need this here, but it seems to stop strange
|
||||
# text encoding issues in the following encode_json call
|
||||
use Encode;
|
||||
$thing->{thing} = decode('utf8', $thing->{thing});
|
||||
my $json = encode_json $thing;
|
||||
$json =~ s/^{".*":"//;
|
||||
$json =~ s/"}$//;
|
||||
@ -503,6 +507,12 @@ sub expand_action_arguments {
|
||||
} else {
|
||||
%h = (args => $input);
|
||||
}
|
||||
|
||||
# not sure why we need this here, but it seems to stop strange
|
||||
# text encoding issues in the following encode_json call
|
||||
use Encode;
|
||||
$h{args} = decode('utf8', $h{args});
|
||||
|
||||
my $jsonargs = encode_json \%h;
|
||||
$jsonargs =~ s/^{".*":"//;
|
||||
$jsonargs =~ s/"}$//;
|
||||
|
Loading…
Reference in New Issue
Block a user