在此处,我想创建一个ANSI编码格式的文本,但是在没有输入中文的情况下,默认会创建为utf-8,代码及结果如下所示:
#include <iostream>
#include <fstream>
#include <locale>
using namespace std;
int main()
{
std::locale::global(std::locale("chs"));
wstring content = L"dawod";
wofstream ofs("save_as_ansi.mnu", ios::app);
ofs.write(content.c_str(), content.size());
ofs.close();
return 0;
}
当内容包含中文时,在其后追加内容,则默认更改为了ANSI编码格式,代码及内容如下:
#include <iostream>
#include <fstream>
#include <locale>
using namespace std;
int main()
{
std::locale::global(std::locale("chs"));
wstring content = L"最爱吃兽奶!!!!";
wofstream ofs("save_as_a