mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 05:49:27 +01:00
Refactor UTF-8 fix
This commit is contained in:
parent
b9a89e10d6
commit
3ada433527
@ -309,18 +309,14 @@ sub execute {
|
|||||||
my $result = "";
|
my $result = "";
|
||||||
my $got_result = 0;
|
my $got_result = 0;
|
||||||
|
|
||||||
while (my $line = decode('UTF-8', <$output>)) {
|
while (my $line = decode('UTF-8', <$output>, sub { sprintf '\\\\x%02X', shift })) {
|
||||||
$line =~ s/[\r\n]+$//;
|
$line =~ s/[\r\n]+$//;
|
||||||
last if $line =~ /^result:end$/;
|
last if $line =~ /^result:end$/;
|
||||||
|
|
||||||
if ($line =~ /^result:/) {
|
if ($line =~ /^result:/) {
|
||||||
$line =~ s/^result://;
|
$line =~ s/^result://;
|
||||||
|
# use JSON::XS->new->decode() for non-utf8 decoding
|
||||||
$line = encode('UTF-8', $line);
|
my $compile_out = JSON::XS->new->decode($line);
|
||||||
my $octets = decode('UTF-8', $line, sub { sprintf '\\\\x%02X', shift });
|
|
||||||
$line = encode('UTF-8', $octets, Encode::FB_CROAK);
|
|
||||||
|
|
||||||
my $compile_out = decode_json($line);
|
|
||||||
$result .= "$compile_out->{result}\n";
|
$result .= "$compile_out->{result}\n";
|
||||||
$got_result = 1;
|
$got_result = 1;
|
||||||
next;
|
next;
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4628,
|
BUILD_REVISION => 4629,
|
||||||
BUILD_DATE => "2023-03-12",
|
BUILD_DATE => "2023-03-12",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user