#!/bin/sh
# Notes: Fancy quotes are handled later in the pipeline.
tr -d '\015' < $1 | iconv -f LATIN1 -t UTF8 | expand | sed \
  -e '# Ligatures not available in Latin-1' \
  -e 's/\[oe\]/œ/g' -e 's/\[O[eE]\]/Œ/g' \
  -e '# Long dashes' \
  -e 's/^----\([^-]\)/——\1/g' -e 's/\([^-]\)----$/\1——/g' \
  -e 's/\([^-]\)----\([^-]\)/\1——\2/g' \
  -e '# em-dashes' \
  -e 's/^--\([^-]\)/—\1/g' -e 's/\([^-]\)--$/\1—/g' \
  -e 's/\([^-]\)--\([^-]\)/\1—\2/g' \
  -e '# en-dashes' \
  -e 's/\([0-9]\)-\([0-9]\)/\1–\2/' \
  > $2
