This file is indexed.

/usr/bin/umap is in libunicode-map8-perl 0.13+dfsg-4build4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#!/usr/bin/perl -w

=head1 NAME

umap - map between different character sets

=head1 SYNOPSIS

 umap [options] <before>:<after>

=head1 DESCRIPTION

The I<umap> script acts as a filter between different encodings and
character sets.

The following options are recognized:

=over 4

=item --list [charset]

Without argument list all character sets recognized.  With a specified
character set list the mapping between this set and Unicode.

=item --strict

Do the stict mapping between the character sets.  The default is to
not translate unmapped character.  With I<--stict> we will remove
unmapped characters or use the default specified with I<--def8> or
I<--def16>.

=item --def8=<charcode>

Set the default 8-bit code for unmapped chars.

=item --def16=<charcode>

Set the default 16-bit code for unmapped chars.

=item --verbose

Generate more verbose output.

=item --version

Print the version number of this program and quit.

=item --help

Print the usage message.

=back

=head1 SEE ALSO

L<Unicode::String>,
L<Unicode::Map8>,
recode(1)

=head1 COPYRIGHT

Copyright 1998 Gisle Aas.

This is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

=cut


use strict;
use Getopt::Long  qw(GetOptions);

my $VERSION = "1.05";

my $list;
my $strict;
my $verbose;
my $def8;
my $def16;
my $before;
my $after;

GetOptions('version' => \&print_version,
	   'help'    => \&usage,
	   'list:s'  => \$list,
	   'verbose' => \$verbose,
	   'strict!' => \$strict,
	   'def8=i'  => \$def8,
	   'def16=i' => \$def16,
	  ) || usage ();


if (defined $list) {
    if (length($list)) {
	list_charset($list);
    } else {
	list_charsets();
    }
    exit;
}

# Try to extract $before/$after from the remaining arguments
$before = shift || $ENV{UMAP_BEFORE} || "latin1";
if (!@ARGV && $before =~ s/([^\\]):/$1\0/) {
    ($before, $after) = split('\0', $before, 2);
}
unless ($after) {
    $after  = shift || $ENV{UMAP_AFTER}  || "utf8";
}
for ($before, $after) {
    s/\\:/:/g;
}
usage() if @ARGV;

print STDERR "$before --> $after\n" if $verbose;


#------------------------------------------------------------------
package MySpace;  # use a new namespace

use Unicode::String 2.00 qw(ucs4 ucs2 utf16 utf7 utf8);

my $bsub = \&{$before};

unless (defined(&$bsub)) {
    require Unicode::Map8;
    my $map = Unicode::Map8->new($before);
    die "Don't know about charset '$before'\n" unless $map;
    $map->nostrict unless $strict;
    $map->default_to16($def16) if defined($def16);
    no strict 'refs';
    *{$before} = sub {	$map->tou($_[0]); };
}

if ($after =~ /^(ucs[24]|utf16|utf[78])$/) {
    *out = sub { print $_[0]->$after(); };
} elsif ($after eq "hex") {
    *out = sub {
	my $hex = $_[0]->hex;
	$hex =~ s/U\+000a\s*/U+000a\n/g;
	print $hex;
    };
} elsif ($after eq "uname") {
    require Unicode::CharName;
    *out = sub {
	for ($_[0]->unpack) {
	    printf "U+%04X   %s\n", $_, Unicode::CharName::uname($_) || "";
	}
    };
} else {
    require Unicode::Map8;
    my $map = Unicode::Map8->new($after);
    die "Don't know about charset '$after'\n" unless $map;
    $map->nostrict unless $strict;
    $map->default_to8($def8) if defined($def8);
    #*out = sub { print $map->to8(${$_[0]}); };
    *out = sub { print $map->to8(${$_[0]}); };
}

if (-t STDIN || $before =~ /^utf[78]$/) {
    # must read a line at the time (should not break encoded chars)
    my $line;
    while (defined($line = <STDIN>)) {
	out(&$bsub($line));
    }
} else {
    my $n;
    my $buf;
    # must read buffers which are multiples of 4 bytes (ucs4)
    while ( $n = read(STDIN, $buf, 512)) {
	#print "$n bytes read\n";
	out(&$bsub($buf));
    }
}


#------------------------------------------------------------------
package main;

sub list_charset
{
    require Unicode::Map8;
    require Unicode::CharName;

    my($charset, $format) = @_;
    my $m = Unicode::Map8->new($charset);
    die "Don't know about charset $charset\n" unless $m;

    my @res8;
    my %map16;
    for (my $i = 0; $i < 256; $i++) {
	my $u = $m->to_char16($i);
	if ($u == Unicode::Map8::NOCHAR()) {
	    push(@res8, sprintf "# 0x%02X unmapped\n", $i) if $verbose;
	} else {
	    push(@res8, sprintf "0x%02X 0x%04X   # %s\n", $i, $u,
		                               Unicode::CharName::uname($u));
	    $map16{$u} = $i;
	}
    }

    my @res16;
    my @blocks;
    for (my $block = 0; $block < 256; $block++) {
	next if $m->_empty_block($block);
	push(@blocks, $block);
	for (my $i = 0; $i < 256; $i++) {
	    my $u = $block*256 + $i;
	    my $c = $m->to_char8($u);
	    next if $c == Unicode::Map8::NOCHAR();
	    next if exists $map16{$u} && $map16{$u} == $c;
	    push(@res16, sprintf "0x%02X 0x%04X   # %s\n", $c, $u,
		                                Unicode::CharName::uname($u));
	}
    }

    print "# Mapping for '$charset'\n";
    print "#\n";
    printf "# %d allocated blocks", scalar(@blocks);
    if (@blocks > 1 || $blocks[0] != 0) {
	print " (", join(", ", map  "#".($_+1), @blocks), ")";
    }
    print "\n";
    print "#\n";
    print @res8;

    if (@res16) {
	print "\n# Extra 16-bit to 8-bit mappings\n";
	print @res16;
    }
}


sub list_charsets
{
    require Unicode::Map8;
    my %set = (
	       ucs4 => {},
	       ucs2 => {utf16 => 1},
	       utf7 => {},
	       utf8 => {},
	      );
    if (opendir(DIR, $Unicode::Map8::MAPS_DIR)) {
	my $f;
	while (defined($f = readdir(DIR))) {
	    next unless -f "$Unicode::Map8::MAPS_DIR/$f";
	    $f =~ s/\.(?:bin|txt)$//;
	    $set{$f} = {} if Unicode::Map8->new($f);
	}
    }

    my $avoid_warning = keys %Unicode::Map8::ALIASES;
    while ( my($alias, $charset) = each %Unicode::Map8::ALIASES) {
	if (exists $set{$charset}) {
	    $set{$charset}{$alias} = 1;
	} else {
	    warn "$charset does not seem to exist (aliased as $alias)\n";
	}
    }

    for (sort keys %set) {
	print "$_";
	if (%{$set{$_}}) {
	    print " ", join(" ", sort keys %{$set{$_}});
	}
	print "\n";
    }
}


sub print_version
{
    require Unicode::Map8;
    my $avoid_warning = $Unicode::Map8::VERSION;
    print <<"EOT";
This is umap version $VERSION (Unicode-Map8-$Unicode::Map8::VERSION)

Copyright 1998, Gisle Aas.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
EOT
    exit 0;
}


sub usage
{
    (my $progname = $0) =~ s,.*/,,;
    die "Usage:\t$progname [options] <before>:<after>
The options are:
  --list [charset]    list character sets
  --strict            use the strict mapping
  --def8 <code>       default 8-bit code for unmapped chars
  --def16 <code>      default 16-bit code for unmapped chars
  --version           print version number and quit
";
}