]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Encode as UTF-8 when sending over the pipe
authorDavid Leadbeater <redacted>
Wed, 13 Aug 2014 19:40:50 +0000 (20:40 +0100)
committerDavid Leadbeater <redacted>
Wed, 13 Aug 2014 19:40:50 +0000 (20:40 +0100)
Fixes script error when the title has unicode in it.

_data/scripts.yaml
scripts/urlinfo.pl

index c173ecabc6fe152a6f8eee950e17fbd34a345100..af41d4d1b04287b0a13da6014dc9079aab6a1611 100644 (file)
   modified: "2014-08-10"
   license: "WTFPL"
   name: "urlinfo"
-  version: "1.1"
+  version: "1.2"
index 8715ebb8415259ee3f3631b708ed562dc6b7cbe6..0a86fe1138cf0e4ef7bbb97a549f1aadeee3d616 100644 (file)
@@ -1,9 +1,10 @@
 use 5.014;
 use utf8;
+use Encode;
 use Irssi;
 use POSIX ();
 
-our $VERSION = "1.1";
+our $VERSION = "1.2";
 our %IRSSI = (
     authors     => 'David Leadbeater',
     contact     => 'dgl@dgl.cx',
@@ -242,10 +243,10 @@ sub msg {
 
     fork_wrapper(sub { # Child
       my($fh) = @_;
-      syswrite $fh, "  " . get_info($site, $uri);
+      syswrite $fh, "  " . encode_utf8(get_info($site, $uri));
     },
     sub { # Parent
-      my($in) = @_;
+      my $in = decode_utf8($_[0]);
       if ($in =~ s/^- //) {
         print "\x{3}4urlinfo error:\x{3} $in";
         return;
@@ -325,7 +326,7 @@ sub fork_wrapper {
       $child->($wfh);
     };
     alarm 0;
-    syswrite $wfh, "- $@" if $@;
+    syswrite $wfh, encode_utf8("- $@") if $@;
     POSIX::_exit(1);
   }
 }
git clone https://git.99rst.org/PROJECT