File Coverage

blib/lib/Unicode/Stringprep/_Common.pm
Criterion Covered Total %
statement 27 27 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 36 37 97.3


line stmt bran cond sub pod time code
1             package Unicode::Stringprep::_Common;
2              
3             require 5.008_003;
4              
5 11     11   55 use strict;
  11         106  
  11         340  
6 11     11   51 use utf8;
  11         16  
  11         52  
7 11     11   234 use warnings;
  11         19  
  11         302  
8              
9 11     11   50 use Exporter;
  11         16  
  11         7364  
10              
11             our $VERSION = "1.10";
12             $VERSION = eval { $VERSION };
13              
14             our @ISA = ('Exporter');
15             our @EXPORT = ('_mk_set', '_mk_map');
16              
17             sub _mk_set {
18 154     154   254 my @data = ();
19 154         2338 foreach my $line (split /\n/, shift) {
20 9581         19459 my($from,$comment) = split /;/, $line;
21 9581         37881 $from =~ s/[^0-9A-Z-]//gi;
22 9581         24925 ($from,my $to) = split(/-/, $from, 2);
23 9581 100       25700 push @data, (hex($from), ($to ? hex($to) : undef));
24             }
25 154         4318 return @data;
26             };
27              
28             sub _mk_map {
29 33     33   81 my @data = ();
30 33         8505 foreach my $line (split /\n/, shift) {
31 24596         64949 my($from,$to,$comment) = split /;/, $line;
32 24596         123505 $from =~ s/[^0-9A-F]//gi;
33 24596         37255 $to =~ s/[^0-9A-F ]//gi;
34 27698 50       117764 push @data,
35             hex($from),
36             join('',map {
37 24596         48282 $_ eq ''
38             ? ''
39             : chr(hex($_))
40             }
41             split(' ', $to));
42             }
43 33         16635 return @data;
44             };
45              
46             1;
47              
48             =head1 NAME
49              
50             Unicode::Stringprep::_Common - Internal functions for C
51              
52             =head1 AUTHOR
53              
54             Claus FErber ECFAERBER@cpan.orgE
55            
56             =head1 LICENSE
57            
58             Copyright 2007-2009 Claus FErber. All rights reserved.
59            
60             This library is free software; you can redistribute it and/or
61             modify it under the same terms as Perl itself.