X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=unicode-expand.pl;h=a46f6b5813148fa902e29097986b28d60c3581d7;hb=HEAD;hp=159d4071aebf3e701b97920dc15d75e2352f4121;hpb=b3aaed733f8f8717d208287a6da15be08e34b05f;p=unicode-expand.git diff --git a/unicode-expand.pl b/unicode-expand.pl index 159d407..a46f6b5 100644 --- a/unicode-expand.pl +++ b/unicode-expand.pl @@ -6,15 +6,16 @@ use Encode qw(decode_utf8); use charnames (); use Irssi; -our $VERSION = '1.50'; +our $VERSION = '1.51'; our %IRSSI = ( authors => 'Jonathan McDowell', contact => 'noodles@earth.li', name => 'unicode-expand', description => 'Expands Unicode characters to include their names', license => 'Public Domain', - changed => "Fri Dec 8 13:39:00 UTC 2017", - url => 'https://the.earth.li/~noodles/unicode-expand.pl', + changed => "Sat 5 Jan 15:42:20 GMT 2019", + url => 'http://www.earth.li/gitweb/?p=unicode-expand.git;a=summary', + # Also https://github.com/u1f35c/unicode-expand ); sub expand_message_public { @@ -54,19 +55,28 @@ sub expand_topic { } sub expand_char { - my ($char) = @_; + my ($string) = @_; - my $name = charnames::viacode(ord $1); - $name = sprintf("{%X}", ord $1) unless defined($name); + my $expansion = ""; - return $name; + for my $c (split //,$string) { + my $name = charnames::viacode(ord $c); + $name = sprintf("{%X}", ord $c) unless defined($name); + if (length($expansion) == 0) { + $expansion .= $name; + } else { + $expansion .= "; " . $name; + } + } + + return $expansion; } sub expand { my ($server, $target, $data) = @_; $data = decode_utf8($data); - $data =~ s{([^\p{Letter}\p{Punctuation}\p{Control}\p{Space}\p{Sc}[:ascii:]])}{ + $data =~ s{([^\p{Letter}\p{Punctuation}\p{Control}\p{Space}\p{Sc}[:ascii:]]+)}{ "${1} [".expand_char($1)."]" }ge;