mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 18:44:33 +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 {
|
sub escape_json {
|
||||||
my ($self, $text) = @_;
|
my ($self, $text) = @_;
|
||||||
my $thing = {thing => $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;
|
my $json = encode_json $thing;
|
||||||
$json =~ s/^{".*":"//;
|
$json =~ s/^{".*":"//;
|
||||||
$json =~ s/"}$//;
|
$json =~ s/"}$//;
|
||||||
@ -503,6 +507,12 @@ sub expand_action_arguments {
|
|||||||
} else {
|
} else {
|
||||||
%h = (args => $input);
|
%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;
|
my $jsonargs = encode_json \%h;
|
||||||
$jsonargs =~ s/^{".*":"//;
|
$jsonargs =~ s/^{".*":"//;
|
||||||
$jsonargs =~ s/"}$//;
|
$jsonargs =~ s/"}$//;
|
||||||
|
Loading…
Reference in New Issue
Block a user