I’d just use
file -bi myfile.txt
to determine the character encoding of a particular file.
A solution with an external dependency but I suspect file is very common nowadays among all semi-modern distro’s.
EDIT:
As a response to Laurence Gonsalves’ comment: b is the option to be ‘brief’ (not include the filename) and i is the shorthand equivalent of --mime so the most portable way (including Mac OSX) then probably is:
file --mime myfile.txt