i3status: check window title sting for utf-8-ness in more correcct manner
This commit is contained in:
@@ -5,6 +5,7 @@ use POSIX;
|
||||
|
||||
use JSON::PP;
|
||||
use utf8;
|
||||
use Encode;
|
||||
use open qw(:std :utf8);
|
||||
|
||||
use threads;
|
||||
@@ -104,14 +105,10 @@ while (1) {
|
||||
$json = $json->canonical(1);
|
||||
$json = $json->space_before(0);
|
||||
$json = $json->space_after(0);
|
||||
$json = $json->indent(1);
|
||||
$json = $json->indent(0);
|
||||
my $str = $json->encode($a);
|
||||
undef $json;
|
||||
|
||||
if ((utf8::valid($str)) and utf8::decode($string)) {
|
||||
syswrite STDOUT, $str . ",\n";
|
||||
}
|
||||
|
||||
syswrite STDOUT, $str . ",\n";
|
||||
undef $str;
|
||||
$shoot = 0;
|
||||
}
|
||||
@@ -195,6 +192,9 @@ sub getfocusedwidowtitlestr() {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user