]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Update unicode.pl
authorPablo Martín Báez Echevarría <redacted>
Mon, 13 Oct 2014 01:22:48 +0000 (23:22 -0200)
committerPablo Martín Báez Echevarría <redacted>
Mon, 13 Oct 2014 03:10:12 +0000 (01:10 -0200)
_data/scripts.yaml
scripts/unicode.pl

index 7d9ba9609f5915c98b99ea0294f5ca9ec8c8c8eb..d66517af893f474e2469ac25ccd42f1e923ae322 100644 (file)
   modified: "2014-07-06"
   license: "WTFPL"
   name: "unicode"
-  version: "1"
+  version: "2"
 
 - authors: "David Leadbeater"
   contact: "dgl@dgl.cx"
index 01ff7bf3bdb33d25b5e5167895bf96df1dba49b2..5970de4b0d29448e0f00f33b6b206df4f4c7633a 100644 (file)
@@ -14,7 +14,7 @@ use POSIX ();
 use Unicode::UCD qw(charblock charblocks charinfo);
 
 use Irssi qw(command_bind command_bind_first);
-our $VERSION = "1";
+our $VERSION = "2";
 our %IRSSI = (
     authors     => 'David Leadbeater',
     contact     => 'dgl@dgl.cx',
@@ -148,6 +148,13 @@ command_bind unicode => sub {
   }
 };
 
+sub hex_str {
+    my $str = shift;
+    use bytes;
+    my @raw_bytes = unpack('C*', $str);
+    return join('', map { '\\x'.sprintf("%02x", $_) } @raw_bytes);
+}
+
 sub print_info {
   my($character, $extra) = @_;
   my $info = charinfo $character;
@@ -166,6 +173,7 @@ sub print_info {
     for(qw(decimal digit numeric upper lower title)) {
       $extra{$_} = $info->{$_} if $info->{$_};
     }
+    $extra{"perl"} = hex_str(chr(hex $info->{code}));
     p " " x (7 + length $info->{code}), join(", ", map { "$_=$extra{$_}" } sort keys %extra);
   }
 }
@@ -204,3 +212,11 @@ sub pipe_input {
   $pipe_in_progress = 0;
   $parent->($line);
 }
+
+command_bind charblocks => sub {
+  my $charblocks_hr = charblocks();
+  my @blocks = sort keys %{$charblocks_hr};
+  foreach(@blocks) {
+    Irssi::print($_,MSGLEVEL_CLIENTCRAP);
+  }
+}
git clone https://git.99rst.org/PROJECT