use uniname-words; my %*SUB-MAIN-OPTS = :named-anywhere; unit sub MAIN( *@words, #= one or more words / regexes Bool :$partial, #= allow for partial matches, default: no Bool :$any, #= show any string matches, default: all Bool :$hex, #= show hex representation, default: no Bool :$name, #= show name, default: no Bool :$char, #= show the actual character, default: no ); sub hex( int $_) { .fmt: ' %X' } sub name( int $_) { "$_.uniname()\n" } sub char( int $_) { .chr ~ ' ' } sub namechar( int $_) { "$_.uniname() $_.chr()\n" } sub hexname( int $_) { "$_.fmt('%5X') $_.uniname()\n" } sub hexchar( int $_) { "$_.fmt('%5X') $_.chr()\n" } sub hexnamechar(int $_) { "$_.fmt('%5X') $_.uniname() $_.chr()\n" } my &mapper = &::( ("hex" if $hex) ~ ("name" if $name) ~ ("char" if $char) ) || &hexnamechar; if @words.map: { if $_ { if .contains(/ \W /) { with try .EVAL { $_ } } else { $_ } } } -> @WORDS { print mapper($_) for uniname-words(@WORDS, :$partial, :$any); print "\n"; } else { note "uw - Look up words or regexes in the installed unicode database.\n"; note $*USAGE; note "\nDefaults to --hex --name --char if none of these specified."; exit 1; } # vim: expandtab shiftwidth=4