diff options
| -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 ); |
