Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- output=$(file --brief --mime-encoding "$1")
- if echo "$output" | grep -qi "ISO-8859"; then
- encoding=$output
- # Backup input file
- cp $1 old_$1
- echo "Text file encoded in $encoding. Converting to UTF-8"
- # Convert to UTF-8 using iconv. It also replaces the original file with the newly
- # encoded one
- # Expected call: iconv -f iso-8859-<1..15> file.txt -t UTF-8 -o file.txt
- iconv -f $encoding $1 -t utf-8 -o $1
- else
- echo "Text file not encode in ISO-8859"
- fi
- $~/Projects/scripts: ./fixEncodingForStations stations.txt
- ./fixEncodingForStations.sh: line 16: 13733 Bus error (core dumped) iconv -f $encoding $1 -t utf-8 -o $1
Add Comment
Please, Sign In to add comment