diff options
| author | KUEPPO <tcheukueppo@tutanota.com> | 2022-10-16 22:16:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-16 22:16:22 +0100 |
| commit | 3aafc7cd4e7c2a519b4651ac21e5d1e81c8f9511 (patch) | |
| tree | 410ab0d9bacf196638c83a4ab2a70a832185ca6b | |
| parent | 101bc159ca59d8e5fc33253db8c2463ae59c142d (diff) | |
| download | perlweeklychallenge-club-3aafc7cd4e7c2a519b4651ac21e5d1e81c8f9511.tar.gz perlweeklychallenge-club-3aafc7cd4e7c2a519b4651ac21e5d1e81c8f9511.tar.bz2 perlweeklychallenge-club-3aafc7cd4e7c2a519b4651ac21e5d1e81c8f9511.zip | |
pwc-186, ch-2 in Perl
| -rw-r--r-- | challenge-186/kueppo-wesley/Perl/ch-2.pl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-186/kueppo-wesley/Perl/ch-2.pl b/challenge-186/kueppo-wesley/Perl/ch-2.pl new file mode 100644 index 0000000000..ddddb1145e --- /dev/null +++ b/challenge-186/kueppo-wesley/Perl/ch-2.pl @@ -0,0 +1,35 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use utf8; + +use Test::More; + +use Encode; +use Unicode::Normalize; + +sub makeover { + my $string = $_[ 0 ]; + + # Decompose unicode characters based on *Compatibility Equivalence* to obtain the + # ascii characters for which impurities have been added to build unicode $string. + $string = NFKD( $string ); + + # Change $string' encoding to ASCII + $string = encode( + 'ascii', + $string, + + # Strip the impurities + sub { '' } + ); + + return $string; +} + +# Testing.. +is( makeover( 'ÃÊÍÒÙ' ), 'AEIOU', "is 'AEIOU' its ascii equivalence?" ); +is( makeover( 'âÊíÒÙ' ), 'aEiOU', "is 'aEiOU' its ascii equivalence?" ); + +done_testing( 2 ); |
