Error of binary reading on dmd 2.067.0

MGW via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 10 05:15:58 PDT 2015


I wish to read bytes from a file using the formatted input, but 
it leads to a mistake - std.utf.UTFException at std\stdio.d(2719): 
Invalid UTF-8 sequence.

// only for dmd 2.067.0
import std.stdio;

int main (string[] args) {
	auto nf = "TestFile.txt";
	// I write down a verifying file
	string s = [65, 225, 67];
	File(nf, "w").write(s);

	// I try to read a file on bytes
	File f1 = File(nf, "r");
	ubyte c;
	while(true) {
		f1.readf("%d", &c); if(f1.eof) break;
		writeln(c, " ");
	}	
	return 0;
}


More information about the Digitalmars-d-learn mailing list