mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-24 12:59:35 +01:00
applets/unicode.pl: limit U+XXXX..U+XXXX
range to 100 characters
This commit is contained in:
parent
3340589207
commit
640f866829
21
applets/unicode.pl
vendored
21
applets/unicode.pl
vendored
@ -11,7 +11,7 @@ use strict;
|
|||||||
use Encode;
|
use Encode;
|
||||||
|
|
||||||
if (not @ARGV) {
|
if (not @ARGV) {
|
||||||
print "Usage: unicode <character> | <U+XXXX code-point> | -s <search regex>\n";
|
print "Usage: unicode <character> | <U+XXXX code-point or U+XXXX..[U+XXXX] range> | -s <search regex>\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,14 +25,29 @@ if ($args =~ s/^-s\s+//) {
|
|||||||
$search = 1;
|
$search = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($args =~ /^(u\+[^.]+)\s*\.\.\s*(.*)$/i) {
|
||||||
|
my ($from, $to) = ($1, $2);
|
||||||
|
|
||||||
|
$from =~ s/u\+//i;
|
||||||
|
$to =~ s/u\+//i;
|
||||||
|
|
||||||
|
$from = hex $from;
|
||||||
|
$to = hex $to;
|
||||||
|
|
||||||
|
if ($to > 0 && $to - $from > 100) {
|
||||||
|
print "Range limited to 100 characters.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $result;
|
my $result;
|
||||||
|
|
||||||
if ($args =~ /^u\+/i) {
|
if ($args =~ /^u\+/i) {
|
||||||
$result = `unicode --color=off \Q$args\E`;
|
$result = `unicode --max=100 --color=off \Q$args\E`;
|
||||||
} elsif ($search) {
|
} elsif ($search) {
|
||||||
$result = `unicode -r --max=100 --color=off \Q$args\E --format 'U+{ordc:04X} {pchar} {name};\n'`;
|
$result = `unicode -r --max=100 --color=off \Q$args\E --format 'U+{ordc:04X} {pchar} {name};\n'`;
|
||||||
} else {
|
} else {
|
||||||
$result = `unicode -s --color=off \Q$args\E --format 'U+{ordc:04X} ({utf8}) {pchar} {name} Category: {category} ({category_desc}) {opt_unicode_block}{opt_unicode_block_desc}{mirrored_desc}{opt_combining}{combining_desc}{opt_decomp}{decomp_desc};\n'`;
|
$result = `unicode -s --max=100 --color=off \Q$args\E --format 'U+{ordc:04X} ({utf8}) {pchar} {name} Category: {category} ({category_desc}) {opt_unicode_block}{opt_unicode_block_desc}{mirrored_desc}{opt_combining}{combining_desc}{opt_decomp}{decomp_desc};\n'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "$result\n";
|
print "$result\n";
|
||||||
|
@ -25,7 +25,7 @@ use PBot::Imports;
|
|||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4639,
|
BUILD_REVISION => 4640,
|
||||||
BUILD_DATE => "2023-03-23",
|
BUILD_DATE => "2023-03-23",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user