From bfabf3e3088a453f09f34bf280ca4205a4d5b77b Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 23 Mar 2023 17:15:19 -0700 Subject: [PATCH] Add applets/unicode.pl A quick-and-dirty simplified interface to https://github.com/garabik/unicode with support for searching by name/description and querying by character or U+XXXX code-point. --- applets/unicode.pl | 40 ++++++++++++++++++++++++++++++++++++++++ lib/PBot/VERSION.pm | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 applets/unicode.pl diff --git a/applets/unicode.pl b/applets/unicode.pl new file mode 100755 index 00000000..7e67f93b --- /dev/null +++ b/applets/unicode.pl @@ -0,0 +1,40 @@ +#!/usr/bin/env perl + +# SPDX-FileCopyrightText: 2023 Pragmatic Software +# SPDX-License-Identifier: MIT + +# quick-and-dirty + +use warnings; +use strict; + +use Encode; + +if (not @ARGV) { + print "Usage: unicode \n"; + exit; +} + +@ARGV = map { decode('UTF-8', $_, 1) } @ARGV; + +my $args = join ' ', @ARGV; + +my $search = 0; + +if ($args =~ s/^-s\s+// || length $args > 1) { + $search = 1; +} + +my $result; + +if ($args =~ /^u\+/i) { + $result = `unicode --color=off \Q$args\E`; +} elsif ($search) { + $result = `unicode -r --color=off \Q$args\E --format 'U+{ordc:04X} {pchar} {name}\n'`; +} else { + $result = `unicode -s --color=off \Q$args\E`; +} + +$result = join '; ', split /\n/, $result; + +print "$result\n"; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index f45ec02c..28b623bc 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4633, + BUILD_REVISION => 4635, BUILD_DATE => "2023-03-23", };