mirror of
				https://github.com/pragma-/pbot.git
				synced 2025-11-04 08:37:24 +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:
		
							parent
							
								
									8b8205ce12
								
							
						
					
					
						commit
						bfabf3e308
					
				
							
								
								
									
										40
									
								
								applets/unicode.pl
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										40
									
								
								applets/unicode.pl
									
									
									
									
										vendored
									
									
										Executable 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";
 | 
			
		||||
@ -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",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user