#!/bin/bash

# a2ps can't deal with UTF-8. Here's a hack to make a2ps work in cases where
# characters used exist in windows-1250 codepage.
#
# USAGE: this script assumes that only one file is being printed and that it is
# the last argument. I couldn't be bothered to do option parsing.
#
# Real solutions that work on fancier Unicode text:
# http://bonobo.gnome.gr.jp/~nakai/u2ps/
# http://u2ps.berlios.de/

# Iain Murray, August 2012

ARGV=("$@")
INFILE="${ARGV[@]: -1:1}"
OPTS=("${ARGV[@]:0:$(($#-1))}")

iconv -f UTF-8 -t windows-1250 "$INFILE" | a2ps -X ms-cp1250 --stdin="$INFILE"  "${OPTS[@]}" -
