1

i3status: check window title sting for utf-8-ness in more correcct manner

This commit is contained in:
eleksir
2017-06-11 19:27:42 +03:00
parent 6519af7f12
commit e6c8a7c676

View File

@@ -5,6 +5,7 @@ use POSIX;
use JSON::PP; use JSON::PP;
use utf8; use utf8;
use Encode;
use open qw(:std :utf8); use open qw(:std :utf8);
use threads; use threads;
@@ -104,14 +105,10 @@ while (1) {
$json = $json->canonical(1); $json = $json->canonical(1);
$json = $json->space_before(0); $json = $json->space_before(0);
$json = $json->space_after(0); $json = $json->space_after(0);
$json = $json->indent(1); $json = $json->indent(0);
my $str = $json->encode($a); my $str = $json->encode($a);
undef $json; undef $json;
if ((utf8::valid($str)) and utf8::decode($string)) {
syswrite STDOUT, $str . ",\n"; syswrite STDOUT, $str . ",\n";
}
undef $str; undef $str;
$shoot = 0; $shoot = 0;
} }
@@ -195,6 +192,9 @@ sub getfocusedwidowtitlestr() {
$str = ' '; $str = ' ';
} }
# not sure about utf-8-ness of this chunk, so try to check it
$str = eval { decode('UTF-8', $str, Encode::FB_CROAK) } // ' ';
return $str; return $str;
} }