Skip to main content

read_file_to_string

Function read_file_to_string 

Source
pub fn read_file_to_string(filename: &str) -> Result<String>
Expand description

This function reads a text file and returns its content as a String, handling different Unicode formats Reads a text file and returns its content as a String, handling different Unicode formats Reads a text file and returns its content as a UTF-8 string.

Automatically handles BOM detection and removal, converting the file content to a standard UTF-8 string regardless of the original encoding format.

§Arguments

  • filename - Path to the file to read

§Returns

Result containing the file content as a String or an IO error