FileIsText function
Determines if the specified file contains plain text content.
Declaration
function FileIsText(const AFilename: string): BooleanArguments
AFilename | File name to examine in the function. |
Function result
True when the file contains plain text content.Description
FileIsText is a
Boolean function used to determine if
the specified file contains plain text content. The overloaded variant that
includes the FileReadable argument is used to examine the content in the file.
FileIsText calls FileOpenUtf8 for the specified file name. The return value is False is the file handle contains feInvalidHandle.
FileIsText checks for (and skips) common Byte Order Marks, such as:
- UTF-8 BOM (Hex $EF $BB $BF)
- UCS-2LE BOM (Hex $FF $FE)
- UCS-2BE BOM (Hex $FE $FF)
Content in the file (up to 1024 characters) is checked to ensure that invalid Null and Control characters are not found in the file. The return value is True when the specified file name exists in the local file system, and does not contain Null or Control characters.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
