summaryrefslogtreecommitdiffstats
path: root/app-text/a2ps/files/cyr2ps
blob: a6022280b38bae5824715b67790ec91637db4e6c (plain)
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
#! /bin/bash

enc=UTF-8
case $1 in
koi|KOI|Koi|koi8|Koi8|KOI8|koi-8|Koi-8|KOI-8|koi-8r|Koi-8r|KOI-8R|koi8r|Koi8r|KOI8R|k|K|Koi8-r|koi8-r|KOI8-R)
    enc=""
    shift
    ;;
alt|Alt|ALT|dos|Dos|DOS|cp866|Cp866|CP866|A|a)
    enc=CP866
    shift
    ;;
win|Win|WIN|cp1251|Cp1251|CP1251|W|w)
    enc=CP1251
    shift
    ;;
UTF-8|utf-8|Utf-8|UTF8|utf8|Utf-8|Unicode|UNICODE|unicode|U|u)
    enc=UTF-8
    shift
    ;;
esac


in=$BASH_ARGV
if [ "$in" == "-" -o -f "$in" ]; then
    arglen=$(($#-1))
    args=${@:1:$arglen}
else
    args=$@
    in="-"
fi

out=""

if [[ " ${args[*]} " != *" -o "* ]]; then
    if [ $in == "-" ]; then
	out="-o -"
    else
	out="-o `basename $in`.ps"
    fi
fi


echo "Encoding: $enc, In: $in, Out: $out, extra args: ${args[*]}"
if [ -n "$enc" ]; then
    cat $in | iconv -f UTF-8 -t KOI8-R -c | a2ps $out $args -
else
    a2ps $out $args $in
fi