Skip to content

Instantly share code, notes, and snippets.

@kathangeorg
Created May 20, 2012 16:16
Show Gist options
  • Save kathangeorg/2758646 to your computer and use it in GitHub Desktop.
Save kathangeorg/2758646 to your computer and use it in GitHub Desktop.
bash - convert to utf-8
local tmp=$(mktemp)
local charset="$(file -bi "$inputfile"|awk -F "=" '{print $2}')"
if [ "$charset" != "utf-8" ]; then
iconv -f "$charset" -t utf8 "$inputfile" -o $tmp
mv "$tmp" "$inputfile"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment