Created
November 29, 2016 11:00
-
-
Save SebDeclercq/a1d393b3fc0cf5fd2b3f1941ea4ab0c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/usr/bin/bash | |
| function versUtf8() { | |
| entree=$1; | |
| sortie=${2:-versUtf8Output.txt}; | |
| charset=$(file -i $entree |grep -oP '(?<=charset=).*'); | |
| if [ $charset == 'unknown-8bit' ] | |
| then | |
| charset='windows-1252' | |
| fi | |
| printf "ENTREE: %20s > %10s\n" $entree $charset; | |
| iconv -f $charset $entree -t utf-16 -o versUtf8.tmp; | |
| iconv -f utf-16le versUtf8.tmp -t utf-8 -o $sortie; | |
| charsetSortie=$(file -i $sortie |grep -oP '(?<=charset=).*'); | |
| printf "SORTIE: %20s > %10s\n" $sortie $charsetSortie; | |
| } | |
| # nous@tour:~/Documents$ versUtf8 ap.csv tutututututututu.txt | |
| # ENTREE: ap.csv > us-ascii | |
| # SORTIE: tutututututututu.txt > utf-8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment