X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=unicode-expand.pl;fp=unicode-expand.pl;h=159d4071aebf3e701b97920dc15d75e2352f4121;hb=b3aaed733f8f8717d208287a6da15be08e34b05f;hp=15aa89eef1d68c94bce82a7a64b6412d130db4dd;hpb=46d0b69d9e61e66214c80b81be91b9291e1677cf;p=unicode-expand.git diff --git a/unicode-expand.pl b/unicode-expand.pl index 15aa89e..159d407 100644 --- a/unicode-expand.pl +++ b/unicode-expand.pl @@ -53,12 +53,21 @@ sub expand_topic { expand($server, $channel, $topic), $nick, $mask); } +sub expand_char { + my ($char) = @_; + + my $name = charnames::viacode(ord $1); + $name = sprintf("{%X}", ord $1) unless defined($name); + + return $name; +} + sub expand { my ($server, $target, $data) = @_; $data = decode_utf8($data); $data =~ s{([^\p{Letter}\p{Punctuation}\p{Control}\p{Space}\p{Sc}[:ascii:]])}{ - "${1} [".charnames::viacode(ord $1)."]" + "${1} [".expand_char($1)."]" }ge; return $data;