template parameter that represents type of string to read
text read from file.
FileException if there is an error reading the file, std.utf.UTFException on UTF decoding error.
import dshould; Path root = createTempPath(); scope(exit) root.remove(); // Write some utf-8 data from the file root.join("test-utf-8.txt").writeFile("Hello World"); // Test that we read correct value root.join("test-utf-8.txt").readFileText.should.equal("Hello World"); // Write some data in UTF-16 with BOM root.join("test-utf-16.txt").writeFile("\uFEFFhi humans"w); // Read utf-16 content auto content = root.join("test-utf-16.txt").readFileText!wstring; // Strip BOM if present. import std.algorithm.searching : skipOver; content.skipOver('\uFEFF'); // Ensure we read correct value content.should.equal("hi humans"w);
Read text content of the file. Technicall just a call to std.file.readText.