44 lines
963 B
Plaintext
44 lines
963 B
Plaintext
|
#!/bin/bash
|
||
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||
|
source "$(dirname "$0")/ulib/ulib" || exit 1; urequire DEFAULTS
|
||
|
|
||
|
function display_help() {
|
||
|
uecho "$scriptname: Enlever ou transformer certaines classes de caractères d'un flux encodé en UTF-8
|
||
|
|
||
|
USAGE
|
||
|
$scriptname [options] [inputfiles...]
|
||
|
|
||
|
OPTIONS
|
||
|
-a, --accents
|
||
|
Transformer les caractères accentués en caractères non accentués."
|
||
|
}
|
||
|
|
||
|
function fix_accents() {
|
||
|
sed '
|
||
|
s/[à]/a/g
|
||
|
s/[éèêë]/e/g
|
||
|
s/[ïî]/i/g
|
||
|
s/[ôö]/o/g
|
||
|
s/[üû]/u/g
|
||
|
s/[ç]/c/g
|
||
|
s/[À]/A/g
|
||
|
s/[ÉÈÊË]/E/g
|
||
|
s/[ÏÎ]/I/g
|
||
|
s/[ÔÖ]/O/g
|
||
|
s/[ÜÛ]/U/g
|
||
|
s/[Ç]/C/g
|
||
|
'
|
||
|
}
|
||
|
|
||
|
accents=
|
||
|
parse_opts "${PRETTYOPTS[@]}" \
|
||
|
--help '$exit_with display_help' \
|
||
|
-a,--accents accents=1 \
|
||
|
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||
|
|
||
|
[ $# -gt 0 ] || set -- /dev/stdin
|
||
|
script="export LANG=fr_FR.UTF-8; $(quoted_args cat "$@")"
|
||
|
[ -n "$accents" ] && script="$script | fix_accents"
|
||
|
|
||
|
eval "$script"
|