1
if (true || '\'); then exec perl -CI "$0" "$@"; fi # ') {}
2
# The above uses the fact that backslash isn't special in single quotes in
3
# shell script, whereas in perl it escapes the following single quote.
5
# The problem it tries to solve is that we want perl to be run with -CI flag
6
# (to have stdin interpreted as utf-8), so we would use `#! /usr/bin/perl -CI',
7
# except that if we do that then perl 5.10 complains about it being too late
8
# to apply -CI if the script is run with `perl -CI ./utf8-to-roff', as we want
9
# to do from the Makefile. The reason we don't do `./utf8-to-roff' from the makefile
10
# is that then we require the #! line to have the right location of perl instead of
11
# just consulting the path. (Similarly, we could use `#! /usr/bin/env perl -CI',
12
# though that still requires that /usr/bin/env exist.) The reason we don't just
13
# remove the `-CI' from the #! line is that then the script couldn't be run correctly
14
# with ./utf8-to-roff.
17
# Converts a man page from utf8 (not understood by groff 1.18) to groff escapes.
18
# I couldn't find any existing tool to convert from utf8 to groff, though I
19
# seem to recall seeing some code to do so somewhere.
21
# Hereby released into public domain by Peter Moulder.
25
# Table generated automatically using:
26
# zcat /usr/share/man/man7/groff_char.7.gz |groff -man -Tutf8| col -pb | grep '\\\['|
27
# perl -CI -nae 'my ($ch, $seq) = @F; if (ord($ch) >= 128) { printf(" 0x\%x, q{\%s},\n", ord($ch), $seq); }'
28
# with č (0x10d) manually translated as cˇ (c\[ah]). (Anyone have a better translation, e.g. using
29
# overprint? \[vc] doesn't work, btw.)
30
# Similarly, ć (0x107) has been manually translated as c´ (c\[aa]), and ń (0x144) as n´ (n\[aa]).
97
0x107, q{c\[aa]}, # Added manually; see above.
98
0x10d, q{c\[ah]}, # Added manually; see above.
107
0x144, q{n\[aa]}, # Added manually; see above.
232
0x220f, q{\[product]},
301
# s/([^ -~])/(ord($1) < 128 ? $1 : defined($map{$1}) ? $map{$1} : sprintf("\\u%4x", $1))/ge;
307
while(defined($ch = getc(STDIN))) {
312
my $out = $map{$ord};
316
die "Untranslatable character \\u" . sprintf("%X", ord($ch)) . " / `$ch'";