C++在读取文件开始时使用IFStand添加65279个BOM字符?
当我想从文件中读取文本并将该文本写入另一个文件时,它会在该文件的开头写入65279个字符。Im使用此代码读取文件:C++在读取文件开始时使用IFStand添加65279个BOM字符?,c++,codeblocks,C++,Codeblocks,当我想从文件中读取文本并将该文本写入另一个文件时,它会在该文件的开头写入65279个字符。Im使用此代码读取文件: int libery(){ string location; textfromcode = ""; ifstream libs; location=loc.c_str(); location.append("/"); location.append(path.c_str()); libs.open(location.c_str
int libery(){
string location;
textfromcode = "";
ifstream libs;
location=loc.c_str();
location.append("/");
location.append(path.c_str());
libs.open(location.c_str());
if (libs.is_open()) {
string lib;
while(!libs.eof()) {
getline(libs,lib);
textfromcode+=lib;
textfromcode+= '\n';
}
libs.close();
}
return 0;
}
我正在从textfromcode变量写入另一个文件。您是如何写入该文件的?65279是UTF-16 BOM的0xFEFF。因此,您试图一次读取一个UTF-16文件一个字节;myfile.open argv[2];如果myfile.is_open{fori=0;i