3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 03:02:47 +01:00

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.
This commit is contained in:
Pragmatic Software 2023-03-23 17:15:19 -07:00
parent 8b8205ce12
commit bfabf3e308
2 changed files with 41 additions and 1 deletions

40
applets/unicode.pl vendored Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env perl
# SPDX-FileCopyrightText: 2023 Pragmatic Software <pragma78@gmail.com>
# SPDX-License-Identifier: MIT
# quick-and-dirty
use warnings;
use strict;
use Encode;
if (not @ARGV) {
print "Usage: unicode <expression>\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";

View File

@ -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",
};