file --mime file.txt
outputs the mime information which includes the encoding.
dev-haskell/iconv http://hackage.haskell.org/package/iconv
String encoding conversion
app-i18n/enca http://gitorious.org/enca
ENCA detects the character coding of a file and converts it if desired