Parameters & Returns
Parameters
filepath
String
encoding
Int
Returns
Quick Summary
Loads an entire file as a string with specified text encoding.
Takes a file path and encoding value (0=ANSI, 1=UTF-8, 2=UTF-16 LE).
Returns the file contents as a string, or an empty string if the file doesn't exist or is empty.
Technical Exegesis...
Reads the entire file at the specified path and returns it as a string using the specified encoding. Returns an empty string if the file doesn't exist or is empty. Encoding values: 0 = ANSI (plain ASCII), 1 = UTF-8 (auto-detects and skips BOM), 2 = UTF-16 LE (converts to UTF-8).
ANSI reads raw bytes. UTF-8 checks for BOM (0xEF 0xBB 0xBF) and skips it if present. UTF-16 reads BOM (0xFF 0xFE) and converts from UTF-16 to UTF-8. Useful for loading text configuration files.