| 1 | package POE::Component::IRC::Plugin::Unicode::UCD; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '0.004'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base 'POE::Component::IRC::Plugin::BaseWrap'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Encode qw/decode encode_utf8/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Unicode::UCD 'charinfo'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | sub _make_default_args { | ||||||||||||||||||||||||||||||||||||||||||
| 15 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | response_event => 'irc_unicode_ucd', | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_default_args: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | trigger => qr/^utf8?\s+(?=\S)/i, | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | sub _make_response_message { | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my ( $self, $in_ref ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_response_message: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | return [ $self->_unip( $in_ref->{what} ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _make_response_event { | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my ( $self, $in_ref ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_response_event: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $in_ref->{result} = $self->_unip( $in_ref->{what} ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return $in_ref; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub _unip { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | ( my $self, $_ ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unip: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $_ = "0x$_" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not s/^[Uu]\+/0x/ and /[A-Fa-f]/ and /^[[:xdigit:]]{2,}\z/
not s/^[Uu]\+/0x/ and /[A-Fa-f]/
MC/DC0%0/3
not s/^[Uu]\+/0x/ and /[A-Fa-f]/ and /^[[:xdigit:]]{2,}\z/
not s/^[Uu]\+/0x/
/[A-Fa-f]/
/^[[:xdigit:]]{2,}\z/
Truth table0%0/4
not(A) and B and C
A= not s/^[Uu]\+/0x/B= /[A-Fa-f]/C= /^[[:xdigit:]]{2,}\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | if !s/^[Uu]\+/0x/ | ||||||||||||||||||||||||||||||||||||||||||
| 37 | and /[A-Fa-f]/ | ||||||||||||||||||||||||||||||||||||||||||
| 38 | and /^[[:xdigit:]]{2,}\z/; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $_ = oct if /^0/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless ( /^\d+\z/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $tmp = decode( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | length > 1 ? 'utf8' : 'iso-8859-1', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | "$_", | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | die "'$_' is not numeric, conversion to unicode failed" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | unless length ($tmp) == 1; | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $_ = ord $tmp; | |||||||||||||||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ( my $err = $@ ) =~ s/ at .* line \d+.*\z//s; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | return $err; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $utf8r = encode_utf8( chr ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $utf8 = join ' ', map "0x$_", unpack '(H2)*', $utf8r; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $x; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return sprintf "U+%X (%s): no match found", $_, $utf8 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | unless $x = charinfo $_; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return "U+$x->{code} ($utf8): $x->{name} [$utf8r]"; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||