From b3aaed733f8f8717d208287a6da15be08e34b05f Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Sat, 5 Jan 2019 15:39:32 +0000 Subject: [PATCH] Fall back to hex value when we can't look up a character We're dependant on Perl for Unicode tables, so if it doesn't have a recent enough set of definitions (e.g. Debian Stretch only has up to Unicode 8) we were getting uninitialized value warnings for Unicode 9/10 characters. Fall back to outputting the hex value for the character. Reported by Lars Wirzenius. --- unicode-expand.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; -- 2.39.2