@TEXTENCODING
— Returns
a guess at the character encoding of a text file.
Syntax:
%@TEXTENCODING[
filename,
flags]
filename | the file to examine |
flags | set 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:
Empty | There is no data in the file. |
OEM | The file is probably not Unicode. |
UTF-16LE | The file is probably 16-bit Unicode. |
UTF-16BE | The file is probably 16-bit Unicode (big-endian). |
UTF-8 | The file is probably UTF-8 encoded Unicode. |
UTF-32LE | The file looks like UTF-32 (little-endian). |
UTF-32BE | The file looks like UTF-32 (big-endian). |
EBCDIC | The 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.