1
我有一個程序,掃描一個大文件尋找一些文本。 這裏加載文件的兩行代碼將它映射到內存中,以避免在文件很大時加載它。不知道文件編碼在objectivec中的內存映射
NSData *buf = [NSData dataWithContentsOfFile:sourceFile options:NSDataReadingMappedIfSafe error:&err];
NSMutableString *string = [[NSMutableString alloc] initWithBytesNoCopy:(void *)buf.bytes length:buf.length encoding:NSASCIIStringEncoding freeWhenDone:NO];
我怎樣才能打開它沒有提供NSASCIIStringEncoding,因爲我不知道有何編碼文件?