I wrote a Perl script that prints characters matching the Unicode property. Everything seems to be working so far.
But he prints ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ
ÿamong the characters matching [^\w]. These characters should rather match \w. Oddly enough, they match \p{Word}.
I tried without success:
map { decode ( "UTF-8", $_ ) }map { pack 'U0C*', unpack 'C*', $_ }
How can I make [^\w]words that do not correspond to these characters?
chars.pl
use warnings;
use strict;
use utf8;
binmode STDOUT, ':utf8';
my $c;
my $cols = 80;
my $arg = shift;
my $regex = qr/$arg/;
for ( map { chr } 0x20 .. 0xFFFF )
{
next if /\p{Unassigned}|\p{NChar}|\p{Cs}/;
if ( $_ =~ $regex )
{
print STDOUT;
print STDOUT "\n" if ++$c % $cols == 0;
}
}
print STDOUT "\n" if defined $c and $c % $cols != 0;
exit 0;
Good:
$ ./chars.pl '\p{Cyrillic}'
ЀЂЃЄЅІЇЈЉЊЋЌЍЎЏ
ѐђѓєѕіїјљњћќѝўџѠѡѢѣѤѥѦѧѨѩѪѫѬѭѮѯѰѱѲѳѴѵѶѷѸѹѺѻѼѽѾѿҀҁ҂҃҄҇ҊҋҌҍҎҏҐґҒғҔҕҖҗҘҙҚқҜҝҞҟҠҡ
ҢңҤҥҦҧҨҩҪҫҬҭҮүҰұҲҳҴҵҶҷҸҹҺһҼҽҾҿӀӁӂӃӄӅӆӇӈӉӊӋӌӍӎӏӐӑӒӓӔӕӖӗӘәӚӛӜӝӞӟӠӡӢӣӤӥӦӧӨөӪӫӬӭӮӯӰӱ
ӲӳӴӵӶӷӸӹӺӻӼӽӾӿԀԁԂԃԄԅԆԇԈԉԊԋԌԍԎԏԐԑԒԓԔԕԖԗԘԙԚԛԜԝԞԟԠԡԢԣԤԥԦԧᴫᵸⷠⷡⷢⷣⷤⷥⷦⷧⷨⷩⷪⷫⷬⷭⷮⷯⷰⷱⷲⷳⷴⷵⷶⷷ
ⷸⷹⷺⷻⷼⷽⷾⷿꙀꙁꙂꙃꙄꙅꙆꙇꙈꙉꙊꙋꙌꙍꙎꙏꙐꙑꙒꙓꙔꙕꙖꙗꙘꙙꙚꙛꙜꙝꙞꙟꙠꙡꙢꙣꙤꙥꙦꙧꙨꙩꙪꙫꙬꙭꙮ꙯꙰꙱꙲꙳꙼꙽꙾ꙿꚀꚁꚂꚃꚄꚅꚆꚇꚈꚉꚊꚋꚌꚍꚎꚏ
ꚐꚑꚒꚓꚔꚕꚖꚗ
$
Good:
$ ./chars.pl '[^\p{Word}]' | grep É
$
Poorly:
$ ./chars.pl '[^\w]' | grep É
°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
$
Perl v5.14.2
source
share