@TEXTENCODING — Returns a guess at the character encoding of a text file.

Syntax:
%@TEXTENCODING[filename,flags]

filenamethe file to examine
flagsset to 1 to also report presence of a BOM

If file begins with a Unicode Byte Order Mark, then it is assumed to be Unicode; the encoding is inferred from the BOM. If the file does not begin with a BOM, the function can only guess at the encoding; the longer the file, the more likely the guess is to be accurate.

Possible return values include:

EmptyThere is no data in the file.
OEMThe file is probably not Unicode.
UTF-16LEThe file is probably 16-bit Unicode.
UTF-16BEThe file is probably 16-bit Unicode (big-endian).
UTF-8The file is probably UTF-8 encoded Unicode.
UTF-32LEThe file looks like UTF-32 (little-endian).
UTF-32BEThe file looks like UTF-32 (big-endian).
EBCDICThe file is probably in some version of EBCDIC.

If flags is 1, and if the file is Unicode and begins with a Byte Order Mark, the phrase with BOM will be appended.

set filename=myfile.txt
echo File %filename is %@textencoding[%filename].

See also: the @LINEENDS and @TEXTFORMAT functions.