Skip to content

Instantly share code, notes, and snippets.

@demofly
Last active August 29, 2015 13:58
Show Gist options
  • Save demofly/9955686 to your computer and use it in GitHub Desktop.
Save demofly/9955686 to your computer and use it in GitHub Desktop.
A script allows to convert any file to utf-8 and send it content to stdout
#!/bin/bash
FFN="$1"
filename=`basename "$FFN"`
encoding=$(uchardet "$FFN")
enc=`echo $encoding | sed 's#^x-mac-#mac#'`
cat "$FFN" | perl -pe 's/\r\n/\n/g' | perl -pe 's/\n\r/\n/g' | perl -pe 's/\r/\n/g' > "$FFN.out"
iconv -f $enc -t UTF-8 "$FFN.out"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment