Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Character-codes/Perl/character-codes-1.pl
Normal file
19
Task/Character-codes/Perl/character-codes-1.pl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
binmode(STDOUT, ':utf8');
|
||||
use Encode;
|
||||
use Unicode::UCD 'charinfo';
|
||||
use List::AllUtils qw(zip natatime);
|
||||
|
||||
for my $c (split //, 'AΑА薵') {
|
||||
my $o = ord $c;
|
||||
my $utf8 = join '', map { sprintf "%x ", ord } split //, Encode::encode("utf8", $c);
|
||||
my $iterator = natatime 2, zip
|
||||
@{['Character', 'Character name', 'Ordinal(s)', 'Hex ordinal(s)', 'UTF-8', 'Round trip']},
|
||||
@{[ $c, charinfo($o)->{'name'}, $o, sprintf("0x%x",$o), $utf8, chr $o, ]};
|
||||
while ( my ($label, $value) = $iterator->() ) {
|
||||
printf "%14s: %s\n", $label, $value
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
19
Task/Character-codes/Perl/character-codes-2.pl
Normal file
19
Task/Character-codes/Perl/character-codes-2.pl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
use utf8;
|
||||
binmode(STDOUT, ':utf8');
|
||||
use Unicode::Normalize 'NFC';
|
||||
use Unicode::UCD qw(charinfo charprop);
|
||||
|
||||
while ('Δ̂🇺🇸👨👩👧👦' =~ /(\X)/g) {
|
||||
my @ordinals = map { ord } split //, my $c = $1;
|
||||
printf "%14s: %s\n"x7 . "\n",
|
||||
'Character', NFC $c,
|
||||
'Character name', join(', ', map { charinfo($_)->{'name'} } @ordinals),
|
||||
'Unicode property', join(', ', map { charprop($_, "Gc") } @ordinals),
|
||||
'Ordinal(s)', join(' ', @ordinals),
|
||||
'Hex ordinal(s)', join(' ', map { sprintf("0x%x", $_) } @ordinals),
|
||||
'UTF-8', join('', map { sprintf "%x ", ord } (utf8::encode($c), split //, $c)),
|
||||
'Round trip', join('', map { chr } @ordinals);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue