line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Unicruft; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6102
|
use 5.008004; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
68
|
|
7
|
1
|
|
|
1
|
|
481
|
use AutoLoader; |
|
1
|
|
|
|
|
1382
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
35
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
196
|
|
9
|
|
|
|
|
|
|
#use Encode; ##-- slower than pack/unpack! |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require XSLoader; |
16
|
|
|
|
|
|
|
XSLoader::load('Unicruft', $VERSION); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Preloaded methods go here. |
19
|
|
|
|
|
|
|
#require Unicruft::Whatever; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
##====================================================================== |
24
|
|
|
|
|
|
|
## Exports |
25
|
|
|
|
|
|
|
##====================================================================== |
26
|
|
|
|
|
|
|
our (%EXPORT_TAGS, @EXPORT_OK, @EXPORT); |
27
|
|
|
|
|
|
|
BEGIN { |
28
|
1
|
|
|
1
|
|
7
|
%EXPORT_TAGS = |
29
|
|
|
|
|
|
|
( |
30
|
|
|
|
|
|
|
std => [qw(latin1_to_utf8 utf8_to_ascii utf8_to_latin1 utf8_to_latin1_de utf8_to_utf8_de)], |
31
|
|
|
|
|
|
|
guts => [qw(ux_latin1_to_utf8 ux_utf8_to_ascii ux_utf8_to_latin1 ux_utf8_to_latin1_de), |
32
|
|
|
|
|
|
|
qw(ux_latin1_bytes ux_utf8_bytes), |
33
|
|
|
|
|
|
|
], |
34
|
|
|
|
|
|
|
); |
35
|
1
|
|
|
|
|
2
|
$EXPORT_TAGS{all} = [@{$EXPORT_TAGS{std}}, @{$EXPORT_TAGS{guts}}]; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
36
|
1
|
|
|
|
|
3
|
@EXPORT_OK = @{$EXPORT_TAGS{all}}; |
|
1
|
|
|
|
|
4
|
|
37
|
1
|
|
|
|
|
288
|
@EXPORT = qw(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
##====================================================================== |
41
|
|
|
|
|
|
|
## Constants |
42
|
|
|
|
|
|
|
##====================================================================== |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
##====================================================================== |
45
|
|
|
|
|
|
|
## Utils |
46
|
|
|
|
|
|
|
##====================================================================== |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
## $u8bytes = ux_utf8_bytes($str) |
49
|
|
|
|
|
|
|
## + returns UTF-8 byte-string encoded version of $str; respects perl UTF-8 flag |
50
|
|
|
|
|
|
|
sub ux_utf8_bytes { |
51
|
0
|
0
|
|
0
|
1
|
|
return utf8::is_utf8($_[0]) ? pack('C0C*',unpack('U0C*',$_[0])) : $_[0]; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
## $l1bytes = ux_latin1_bytes($str) |
55
|
|
|
|
|
|
|
## + returns Latin-1 byte-string encoded version of $str; respects perl UTF-8 flag |
56
|
|
|
|
|
|
|
sub ux_latin1_bytes { |
57
|
0
|
0
|
|
0
|
1
|
|
return utf8::is_utf8($_[0]) ? pack('C0C*',unpack('U0U*',$_[0])) : $_[0]; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
##====================================================================== |
61
|
|
|
|
|
|
|
## Wrappers |
62
|
|
|
|
|
|
|
##====================================================================== |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
## $u8str = latin1_to_utf8($l1str) |
65
|
|
|
|
|
|
|
sub latin1_to_utf8 { |
66
|
0
|
|
|
0
|
1
|
|
ux_latin1_to_utf8(ux_latin1_bytes($_[0])); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## $astr = utf8_to_ascii($u8str) |
70
|
|
|
|
|
|
|
sub utf8_to_ascii { |
71
|
0
|
|
|
0
|
1
|
|
ux_utf8_to_ascii(ux_utf8_bytes($_[0])); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
## $l1str = utf8_to_latin1($u8str) |
75
|
|
|
|
|
|
|
sub utf8_to_latin1 { |
76
|
0
|
|
|
0
|
1
|
|
ux_utf8_to_latin1(ux_utf8_bytes($_[0])); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
## $destr = utf8_to_latin1_de($u8str) |
80
|
|
|
|
|
|
|
sub utf8_to_latin1_de { |
81
|
0
|
|
|
0
|
1
|
|
ux_utf8_to_latin1_de(ux_utf8_bytes($_[0])); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
## $destr = utf8_to_utf8_de($u8str) |
85
|
|
|
|
|
|
|
sub utf8_to_utf8_de { |
86
|
0
|
|
|
0
|
1
|
|
utf8::upgrade(my $s = ux_utf8_to_latin1_de(ux_utf8_bytes($_[0]))); |
87
|
0
|
|
|
|
|
|
return $s; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
##====================================================================== |
91
|
|
|
|
|
|
|
## Exports: finish |
92
|
|
|
|
|
|
|
##====================================================================== |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |