line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CBOR::Free::X::WideCharacter; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
756
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent qw( CBOR::Free::X::Base ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
458
|
use Text::Control (); |
|
1
|
|
|
|
|
306
|
|
|
1
|
|
|
|
|
188
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub _new { |
11
|
12
|
|
|
12
|
|
539
|
my ($class, $value) = @_; |
12
|
|
|
|
|
|
|
|
13
|
12
|
|
|
|
|
32
|
my $hex = Text::Control::to_hex($value); |
14
|
|
|
|
|
|
|
|
15
|
12
|
|
|
|
|
288
|
$hex = _escape_multibyte($hex); |
16
|
|
|
|
|
|
|
|
17
|
12
|
|
|
|
|
45
|
return $class->SUPER::_new("Cannot encode wide character(s): “$hex”"); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _escape_multibyte { |
21
|
12
|
|
|
12
|
|
26
|
my ($value) = @_; |
22
|
|
|
|
|
|
|
|
23
|
12
|
|
|
|
|
45
|
for my $i ( reverse 0 .. (length($value) - 1) ) { |
24
|
88
|
|
|
|
|
148
|
my $chr = substr( $value, $i, 1 ); |
25
|
|
|
|
|
|
|
|
26
|
88
|
100
|
|
|
|
174
|
if (ord $chr > 0xff) { |
27
|
12
|
|
|
|
|
69
|
substr( $value, $i, 1, sprintf "\\x{%x}", ord $chr ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
12
|
|
|
|
|
39
|
utf8::encode($value); |
32
|
|
|
|
|
|
|
|
33
|
12
|
|
|
|
|
29
|
return "$value"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |