RecodeData/US_ASCII.pm untested

filter: Statementstmt 0.0% 0 / 18 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 6 SCAR 33.6
CC
6
Cov
0%
_recode
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 28.7
1 #! /bin/false
2  
3 # vim: set autoindent shiftwidth=4 tabstop=4:
4  
5 # Conversion routines for US-ASCII.
6 # Copyright (C) 2002-2026 Guido Flohr <guido.flohr@cantanea.com>,
7 # all rights reserved.
8  
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13  
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18  
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21  
22 package Locale::RecodeData::US_ASCII;
23  
24 use strict;
25  
26 require Locale::RecodeData;
27 use base qw(Locale::RecodeData);
28  
29 sub _recode
30 {
31 if ($_[0]->{_from} eq 'INTERNAL') {
32 # FIXME: Maybe the lookup is cheaper than the call to chr().
33 $_[1] = join '',
34 map $_ > 0x7f ? '?' : chr $_,
35 @{$_[1]};
36 } elsif ($_[0]->{_to} eq 'UTF-8') {
37 # FIXME: Maybe the lookup is cheaper than the call to chr().
38 $_[1] = join '',
39 map $_ > 0x7f ? "\xef\xbf\xbd" : chr $_, unpack 'C*', $_[1];
40 } else {
41 $_[1] = [ map { $_ > 0x7f ? 0xfffd : $_ } unpack 'C*', $_[1] ];
42 }
43  
44 return 1;
45 }
46  
47 1;
48  
49 __END__