2013-03-03 11:19:50 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
2013-10-06 19:54:15 +02:00
|
|
|
|
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
2014-11-12 16:15:39 +01:00
|
|
|
|
cat <<EOF
|
2013-10-06 19:54:15 +02:00
|
|
|
|
Usage: ${0##*/} [FILES]
|
|
|
|
|
|
2014-01-06 17:56:56 +01:00
|
|
|
|
Convert non-ASCII characters to their ASCII equivalent. If no files are
|
|
|
|
|
provided, use stdin.
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
|
|
|
|
-i: If files are provided, convert them in-place.
|
2013-03-03 11:19:50 +01:00
|
|
|
|
|
|
|
|
|
EOF
|
2014-11-12 16:15:39 +01:00
|
|
|
|
exit
|
2013-03-03 11:19:50 +01:00
|
|
|
|
fi
|
|
|
|
|
|
2014-01-06 11:24:43 +01:00
|
|
|
|
unset OPT
|
2014-01-06 17:56:56 +01:00
|
|
|
|
if [ "$1" = "-i" ]; then
|
2014-11-12 16:15:39 +01:00
|
|
|
|
OPT=-i
|
|
|
|
|
shift
|
2013-10-06 19:54:15 +02:00
|
|
|
|
fi
|
2014-01-06 11:24:43 +01:00
|
|
|
|
|
2014-01-06 17:32:13 +01:00
|
|
|
|
## Note that we also use 'sed -i' to edit files instead of 'ex'. Otherwise the
|
|
|
|
|
## code looks ugly if we try to handle both stdin and files with only one
|
|
|
|
|
## call. Besides, ex does not support multiple file editing.
|
2014-01-06 11:24:43 +01:00
|
|
|
|
sed $OPT \
|
2014-11-12 16:15:39 +01:00
|
|
|
|
-e 's/[áàâä]/a/g' \
|
|
|
|
|
-e 's/[éèêë]/e/g' \
|
|
|
|
|
-e 's/[íìîï]/i/g' \
|
|
|
|
|
-e 's/[óòôö]/o/g' \
|
|
|
|
|
-e 's/[úùûü]/u/g' \
|
|
|
|
|
-e 's/[ýỳŷÿ]/y/g' \
|
|
|
|
|
-e 's/[ÁÀÂÄ]/A/g' \
|
|
|
|
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/g' \
|
|
|
|
|
-e 's/[÷]/\//g' \
|
|
|
|
|
-e 's/[↓]/|/g' \
|
|
|
|
|
-e 's/[↑]/^/g' \
|
|
|
|
|
-e 's/[←]/<=/g' \
|
|
|
|
|
-e 's/[→]/=>/g' \
|
|
|
|
|
"$@"
|