functions
fhLoadTextFile
Description
Loads a text file into a string.
This function never sets the conversion loss flag.
See also fhSaveTextFile.
Minimum FH Version
7 (ANSI file format requires a minimum of 7.0.10)
Syntax
strContents = fhLoadTextFile(strFilePath[, strFileFormat])
Parameters
- strFilePath
- Full path name of the text file to load. The file must be in UTF-8 format, UTF-16LE or ANSI format.
- strFileFormat
- The text format of the file. Optional. If supplied, this must be "UTF-8", "UTF-16LE" (UTF-16, little endian) or "ANSI". If not supplied it defaults to "UTF-8".
Returns
- strContents
- String or nil. The contents of the file - or nil if the load failed. Note: regardless of the file format, the encoding of the string returned will match the current string encoding - i.e. UTF8 or ANSI. For more information, please see String Encoding and Unicode.
Example
local strText = fhLoadTextFile(strFilePath, "UTF-16LE"); if (strText) fhMessageBox(strText); else fhMessageBox("Load failed");