Filename | /usr/share/perl5/MARC/Charset/Code.pm |
Statements | Executed 20 statements in 1.01ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.21ms | 3.79ms | BEGIN@8 | MARC::Charset::Code::
1 | 1 | 1 | 27µs | 34µs | BEGIN@3 | MARC::Charset::Code::
1 | 1 | 1 | 18µs | 1.95ms | BEGIN@5 | MARC::Charset::Code::
1 | 1 | 1 | 16µs | 39µs | BEGIN@4 | MARC::Charset::Code::
1 | 1 | 1 | 16µs | 72µs | BEGIN@7 | MARC::Charset::Code::
1 | 1 | 1 | 14µs | 67µs | BEGIN@6 | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | char_value | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | charset_name | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | charset_value | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | default_charset_group | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | get_escape | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | marc8_hash_code | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | marc_value | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | to_string | MARC::Charset::Code::
0 | 0 | 0 | 0s | 0s | utf8_hash_code | MARC::Charset::Code::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package MARC::Charset::Code; | ||||
2 | |||||
3 | 3 | 42µs | 2 | 41µs | # spent 34µs (27+7) within MARC::Charset::Code::BEGIN@3 which was called:
# once (27µs+7µs) by MARC::Charset::Table::BEGIN@38 at line 3 # spent 34µs making 1 call to MARC::Charset::Code::BEGIN@3
# spent 7µs making 1 call to strict::import |
4 | 3 | 43µs | 2 | 62µs | # spent 39µs (16+23) within MARC::Charset::Code::BEGIN@4 which was called:
# once (16µs+23µs) by MARC::Charset::Table::BEGIN@38 at line 4 # spent 39µs making 1 call to MARC::Charset::Code::BEGIN@4
# spent 23µs making 1 call to warnings::import |
5 | 3 | 48µs | 2 | 3.88ms | # spent 1.95ms (18µs+1.93) within MARC::Charset::Code::BEGIN@5 which was called:
# once (18µs+1.93ms) by MARC::Charset::Table::BEGIN@38 at line 5 # spent 1.95ms making 1 call to MARC::Charset::Code::BEGIN@5
# spent 1.93ms making 1 call to base::import |
6 | 3 | 43µs | 2 | 120µs | # spent 67µs (14+53) within MARC::Charset::Code::BEGIN@6 which was called:
# once (14µs+53µs) by MARC::Charset::Table::BEGIN@38 at line 6 # spent 67µs making 1 call to MARC::Charset::Code::BEGIN@6
# spent 53µs making 1 call to Exporter::import |
7 | 3 | 45µs | 2 | 128µs | # spent 72µs (16+56) within MARC::Charset::Code::BEGIN@7 which was called:
# once (16µs+56µs) by MARC::Charset::Table::BEGIN@38 at line 7 # spent 72µs making 1 call to MARC::Charset::Code::BEGIN@7
# spent 56µs making 1 call to Exporter::import |
8 | 3 | 774µs | 2 | 4.38ms | # spent 3.79ms (1.21+2.57) within MARC::Charset::Code::BEGIN@8 which was called:
# once (1.21ms+2.57ms) by MARC::Charset::Table::BEGIN@38 at line 8 # spent 3.79ms making 1 call to MARC::Charset::Code::BEGIN@8
# spent 594µs making 1 call to Exporter::import |
9 | |||||
10 | 1 | 10µs | 1 | 384µs | MARC::Charset::Code # spent 384µs making 1 call to Class::Accessor::mk_accessors |
11 | ->mk_accessors(qw(marc ucs name charset is_combining alt)); | ||||
12 | |||||
13 | =head1 NAME | ||||
14 | |||||
- - | |||||
61 | sub char_value() | ||||
62 | { | ||||
63 | return chr(hex(shift->ucs())); | ||||
64 | } | ||||
65 | |||||
66 | =head2 marc_value() | ||||
67 | |||||
- - | |||||
72 | sub marc_value | ||||
73 | { | ||||
74 | my $code = shift; | ||||
75 | my $marc = $code->marc(); | ||||
76 | return chr(hex($marc)) unless $code->charset_name eq 'CJK'; | ||||
77 | return | ||||
78 | chr(hex(substr($marc,0,2))) . | ||||
79 | chr(hex(substr($marc,2,2))) . | ||||
80 | chr(hex(substr($marc,4,2))); | ||||
81 | } | ||||
82 | |||||
83 | |||||
84 | =head2 charset_name() | ||||
85 | |||||
- - | |||||
90 | sub charset_name() | ||||
91 | { | ||||
92 | return MARC::Charset::Constants::charset_name(shift->charset_value()); | ||||
93 | } | ||||
94 | |||||
95 | =head2 to_string() | ||||
96 | |||||
- - | |||||
101 | sub to_string | ||||
102 | { | ||||
103 | my $self = shift; | ||||
104 | my $str = | ||||
105 | $self->name() . ': ' . | ||||
106 | 'charset_code=' . $self->charset() . ' ' . | ||||
107 | 'marc=' . $self->marc() . ' ' . | ||||
108 | 'ucs=' . $self->ucs() . ' '; | ||||
109 | |||||
110 | $str .= ' combining' if $self->is_combining(); | ||||
111 | return $str; | ||||
112 | } | ||||
113 | |||||
114 | |||||
115 | =head2 marc8_hash_code() | ||||
116 | |||||
- - | |||||
123 | sub marc8_hash_code | ||||
124 | { | ||||
125 | my $self = shift; | ||||
126 | return sprintf('%s:%s', $self->charset_value(), $self->marc_value()); | ||||
127 | } | ||||
128 | |||||
129 | |||||
130 | =head2 utf8_hash_code() | ||||
131 | |||||
- - | |||||
136 | sub utf8_hash_code | ||||
137 | { | ||||
138 | return int(hex(shift->ucs())); | ||||
139 | } | ||||
140 | |||||
141 | |||||
142 | =head2 default_charset_group | ||||
143 | |||||
- - | |||||
149 | sub default_charset_group | ||||
150 | { | ||||
151 | my $charset = shift->charset_value(); | ||||
152 | |||||
153 | return 'G0' | ||||
154 | if $charset eq ASCII_DEFAULT | ||||
155 | or $charset eq GREEK_SYMBOLS | ||||
156 | or $charset eq SUBSCRIPTS | ||||
157 | or $charset eq SUPERSCRIPTS | ||||
158 | or $charset eq BASIC_LATIN | ||||
159 | or $charset eq BASIC_ARABIC | ||||
160 | or $charset eq BASIC_CYRILLIC | ||||
161 | or $charset eq BASIC_GREEK | ||||
162 | or $charset eq BASIC_HEBREW | ||||
163 | or $charset eq CJK; | ||||
164 | |||||
165 | return 'G1'; | ||||
166 | } | ||||
167 | |||||
168 | |||||
169 | =head2 get_marc8_escape | ||||
170 | |||||
- - | |||||
176 | sub get_escape | ||||
177 | { | ||||
178 | my $charset = shift->charset_value(); | ||||
179 | |||||
180 | return ESCAPE . $charset | ||||
181 | if $charset eq ASCII_DEFAULT | ||||
182 | or $charset eq GREEK_SYMBOLS | ||||
183 | or $charset eq SUBSCRIPTS | ||||
184 | or $charset eq SUPERSCRIPTS; | ||||
185 | |||||
186 | return ESCAPE . SINGLE_G0_A . $charset | ||||
187 | if $charset eq ASCII_DEFAULT | ||||
188 | or $charset eq BASIC_LATIN | ||||
189 | or $charset eq BASIC_ARABIC | ||||
190 | or $charset eq BASIC_CYRILLIC | ||||
191 | or $charset eq BASIC_GREEK | ||||
192 | or $charset eq BASIC_HEBREW; | ||||
193 | |||||
194 | return ESCAPE . SINGLE_G1_A . $charset | ||||
195 | if $charset eq EXTENDED_ARABIC | ||||
196 | or $charset eq EXTENDED_LATIN | ||||
197 | or $charset eq EXTENDED_CYRILLIC; | ||||
198 | |||||
199 | return ESCAPE . MULTI_G0_A . CJK | ||||
200 | if $charset eq CJK; | ||||
201 | } | ||||
202 | |||||
203 | =head2 charset_value | ||||
204 | |||||
- - | |||||
209 | sub charset_value | ||||
210 | { | ||||
211 | return chr(hex(shift->charset())); | ||||
212 | } | ||||
213 | |||||
- - | |||||
216 | 1 | 6µs | 1; |