Hi guys,
I use nmh for my mail; plain text mails are displayed with less(1). Unfortunately, since my xterm uses UTF-8 by default, any ISO8859 mails will tend to have �’s everywhere.
I thought I’d fix this by piping output through a simple script first:
Code:
#!/bin/sh
while read input
do
echo $input | file - | grep 8859 > /dev/null
if [[ $? = 0 ]]; then
echo $input | iconv -f ISO-8859-1 -t UTF-8
else
echo $input
fi
done
This works, but makes reading my mail noticeably slower:
Code:
$ time u8conv.sh < /etc/hosts >/dev/null
0m0.22s real 0m0.11s user 0m0.11s system
$ time cat /etc/hosts >/dev/null
0m0.00s real 0m0.00s user 0m0.00s system
Is there an obvious way to make the script faster? Perhaps there’s a better way to solve my problem that I’ve missed.