2013-03-03 11:19:50 +01:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
2013-10-06 19:54:15 +02:00
|
|
|
|
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
2013-03-03 11:19:50 +01:00
|
|
|
|
cat <<EOF
|
2013-10-06 19:54:15 +02:00
|
|
|
|
Usage: ${0##*/} [FILES]
|
|
|
|
|
|
|
|
|
|
Convert non-ASCII characters to their ASCII equivalent. If files are provided,
|
|
|
|
|
convert them in-place. Otherwise convert standard input to standard output.
|
2013-03-03 11:19:50 +01:00
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
2013-10-06 19:54:15 +02:00
|
|
|
|
_asciify()
|
|
|
|
|
{
|
|
|
|
|
unset OPT
|
|
|
|
|
if [ $# -ge 1 ]; then
|
|
|
|
|
OPT=-i
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sed $OPT \
|
2013-03-03 11:19:50 +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' \
|
|
|
|
|
-e 's/[ÉÈÊË]/E/g' \
|
|
|
|
|
-e 's/[ÍÌÎÏ]/I/g' \
|
|
|
|
|
-e 's/[ÓÒÔÖ]/O/g' \
|
|
|
|
|
-e 's/[ÚÙÛÜ]/U/g' \
|
|
|
|
|
-e 's/[ÝỲŶŸ]/Y/g' \
|
|
|
|
|
-e 's/[ñ]/n/g' \
|
|
|
|
|
-e 's/[œ]/oe/g' \
|
|
|
|
|
-e 's/[Œ]/Oe/g' \
|
|
|
|
|
-e 's/[æ]/ae/g' \
|
|
|
|
|
-e 's/[Æ]/Ae/g' \
|
|
|
|
|
-e 's/[ç]/c/g' \
|
|
|
|
|
-e 's/[Ç]/C/g' \
|
|
|
|
|
-e 's/[ß]/ss/g' \
|
|
|
|
|
-e 's/[«»„“”‚‘’]/"/g' \
|
|
|
|
|
-e 's/[©]/(C)/g' \
|
|
|
|
|
-e 's/[®]/(R)/g' \
|
|
|
|
|
-e 's/[™]/(TM)/g' \
|
|
|
|
|
-e 's/[¥]/Y/g' \
|
|
|
|
|
-e 's/[Ð]/D/g' \
|
|
|
|
|
-e 's/[ŀ]/l/g' \
|
|
|
|
|
-e 's/[Ŀ]/L/g' \
|
|
|
|
|
-e 's/[€]/euro/g' \
|
|
|
|
|
-e 's/[¢]/cent/g' \
|
|
|
|
|
-e 's/[£]/pound/g' \
|
|
|
|
|
-e 's/[µ]/mu/g' \
|
|
|
|
|
-e 's/[²]/^2/g' \
|
|
|
|
|
-e 's/[³]/^3/g' \
|
|
|
|
|
-e 's/[¡]/!/g' \
|
|
|
|
|
-e 's/[¿]/?/g' \
|
|
|
|
|
-e 's/[–‑]/-/g' \
|
|
|
|
|
-e 's/[…]/.../g' \
|
|
|
|
|
-e 's/[≤]/<=/g' \
|
|
|
|
|
-e 's/[≥]/>=/g' \
|
|
|
|
|
-e 's/[±]/+\/-/g' \
|
|
|
|
|
-e 's/[≠]/!=/g' \
|
|
|
|
|
-e 's/[⋅]/./g' \
|
|
|
|
|
-e 's/[×]/x/g' \
|
|
|
|
|
-e 's/[÷]/\//g' \
|
|
|
|
|
-e 's/[↓]/|/g' \
|
|
|
|
|
-e 's/[↑]/^/g' \
|
|
|
|
|
-e 's/[←]/<=/g' \
|
|
|
|
|
-e 's/[→]/=>/g' \
|
2013-10-06 19:54:15 +02:00
|
|
|
|
"$@"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ $# -ge 1 ]; then
|
|
|
|
|
for i; do
|
|
|
|
|
_asciify "$i"
|
|
|
|
|
done
|
|
|
|
|
else
|
2013-10-23 10:32:49 +02:00
|
|
|
|
_asciify
|
2013-10-06 19:54:15 +02:00
|
|
|
|
fi
|