pub fn read_source_file(path: &Path) -> Result<FileReadResult, TldrError>Expand description
Read a source file with encoding detection.
This function:
- Reads the file as bytes
- Checks for and strips UTF-8 BOM
- Detects UTF-16 BOM and reports unsupported
- Attempts UTF-8 decoding
- Falls back to lossy decoding if needed
- Detects binary files (contains null bytes)
§Arguments
path- Path to the file to read
§Returns
Ok(FileReadResult::Ok(content))- Valid UTF-8 contentOk(FileReadResult::Lossy { content, warning })- Lossy decoded content with warningOk(FileReadResult::Binary)- File is binaryErr(TldrError)- IO error