Created
November 6, 2014 13:51
-
-
Save kamikat/b98801acbae284e2cdd7 to your computer and use it in GitHub Desktop.
Guessing text file encoding and outputs UTF-8 encoded text.
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
#!/bin/bash | |
for ENCODING in "gbk" "utf-8" "ucs-2" | |
do | |
(iconv -f $ENCODING -t utf-8 "$1" 1>/dev/null 2>&1) && iconv -f $ENCODING -t utf-8 "$1" && exit 0 | |
done | |
echo >&2 "[ERROR] Unknown Characterset \"" "$1" "\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment