/usr/bin/latex2utf8 is in liblatex-decode-perl 0.03-1.
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 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
use strict;
use warnings;
#no warnings 'utf8';
use Carp;
use LaTeX::Decode;
use Encode;
binmode(STDOUT, ':utf8');
use Getopt::Long qw/:config no_ignore_case/;
my $opts = {};
GetOptions(
$opts,
'help|h|?',
'version|v',
'inputencoding|i=s',
'filter|f!',
'scheme|s=s',
'normalize|n!',
'normalization|N=s',
'strip_outer_braces|b!'
);
our $VERSION = '0.03';
die usage() if exists $opts->{'help'};
die version() if exists $opts->{'version'};
my $text;
if ($opts->{filter}) {
while (<STDIN>) {
$text .= $_
}
croak "Huh? There is nothing to convert!\n" if (!$text or $text =~ /^\s*$/)
}
else {
my $infile = $ARGV[0] or die usage();
require File::Slurp;
$text = File::Slurp::read_file($infile) or croak "Cannot read input file '$infile'";
}
#Options to pass to latex_decode()
my %ld_opts = ();
if (exists $opts->{inputencoding}) {
my $encoding = $opts->{inputencoding};
$text = decode($encoding, $text);
}
if (exists $opts->{scheme} ) {
$ld_opts{scheme} = $opts->{scheme}
}
if (exists $opts->{normalize} ) {
die "The option 'normalize' has been removed:\n\t use '--normalization 0' to suppress normalization\n"
}
if (exists $opts->{normalization} ) {
if (!$opts->{normalization} or $opts->{normalization} eq 'undef') {
$ld_opts{normalize} = 0
} else {
$ld_opts{normalization} = $opts->{normalization}
}
}
if (exists $opts->{strip_outer_braces} ) {
$ld_opts{strip_outer_braces} = $opts->{strip_outer_braces}
}
$text = decode_utf8($text);
print latex_decode($text, %ld_opts);
sub version {
my $me = "latex2utf8";
qq[
$me Version: $VERSION
\n]
}
sub usage {
qq/
Usage: latex2utf8 infile > outfile
Options:
--help|-h Show this help message.
--version|-v Display version number.
--filter|-f Use script as a filter, using standard input instead of
an input file
--inputencoding|-i [encoding]
Encoding used in the input file (or STDIN if using
the option --filter)
--scheme|-s Decoding scheme to use (possible values are 'base',
'extra', 'full'; default = 'extra')
--normalization|-N [form]
The normalization form to use (default = 'NFC')
(with a value of 0 or undef the output will not be
normalized with Unicode::Normalize)
--strip_outer_braces|-b
Remove curly braces around characters (boolean)
(e.g. "saut{\\\'e}" => "sauté")
(See "perldoc LaTeX::Decode" for more information on the last three options.)
Example: latex2utf8 -i latin1 -s base -N NFD infile.tex > outfile.tex
\n/
}
=pod
=encoding utf8
=head1 NAME
C<latex2utf8> - converts LaTeX encoding to UTF-8
=head1 VERSION
Version 0.03
=head1 SYNOPSIS
latex2utf8 file.tex > utf8file.tex
echo '\textexclamdown\textctj\alpha\textphook\texthvlig!' | latex2utf8 --scheme full --filter
=head1 DESCRIPTION
Command-line utility to convert a LaTeX-encoded file to UTF-8.
See the output of C<latex2utf8 --help> for usage and options.
=head1 AUTHOR
François Charette, C<< <firmicus@cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-latex-decode at
rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-Decode>. I will be
notified, and then you'll automatically be notified of progress on your bug as
I make changes.
=head1 COPYRIGHT & LICENSE
Copyright 2009-2010 François Charette, all rights reserved.
This module is free software. You can redistribute it and/or
modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
=cut
# vim: set tabstop=4 shiftwidth=4 expandtab:
|