Unicode-Stringprep

 view release on metacpan or  search on metacpan

lib/Unicode/Stringprep.pm  view on Meta::CPAN

sub _NFKC_3_2 {
  my $string = shift;

  ## pre-map characters corrected in Corrigendum #4
  ##
  no warnings 'utf8';
  $string =~ tr/\x{2F868}\x{2F874}\x{2F91F}\x{2F95F}\x{2F9BF}/\x{2136A}\x{5F33}\x{43AB}\x{7AAE}\x{4D57}/;

  ## only normalize runs of assigned characters
  ##
  my @s = split m/($is_Unassigned+)/o, $string;

  for( my $i = 0; $i <= $#s ; $i+=2 ) { # skips delimiters == is_Unassigned
    no warnings 'utf8';
    $s[$i] = Unicode::Normalize::NFKC($s[$i]);
  }
  return join '', @s;
}

sub _check_unassigned {
  if( shift =~ m/($is_Unassigned)/os ) {

t/32_nfkc_3_2.t  view on Meta::CPAN

use utf8;

no warnings 'utf8';

use Test::More;
use Test::NoWarnings;

use Unicode::Stringprep;

my @data; while(<DATA>) {
  my @c = map { s/^\s+|\s+$//g;$_; } split m/;/, $_, 3;
  push @data, \@c if $#c > 1;
}

plan tests => ($#data+1) + 2;
ok($#data > 2, 'number of test patterns');

my $func = Unicode::Stringprep->new('3.2', undef, 'KC');

foreach my $d (@data) {
  $d->[2] = sprintf('U+%s - %s', uc($d->[0]), $d->[2]) 



( run in 0.544 second using v1.01-cache-2.11-cpan-71847e10f99 )