see encoding of file txt linux

C++
file <file.txt>
file -bi <file.txt>
Source

Also in C++: