16,818
社区成员




QString file_path = QFileDialog::getExistingDirectory(this, "请选择文件路径...", "./");
std::ofstream& f = (*l)[token];
//网上说std::string是utf-8【多字节】的。那我这里姑且认为是utf-8的
//QString【unicode】【宽字符】->std::string【utf8】【多字节字符】
//- >open底层实现-> C语言的 【多字节字符】转【宽字节字符】:C语言的这个转换“默认且确认”为当前的locale设置【默认为ANSI C】的字符集
//但输入的std::string是【utf8】字符集的【多字节字符串】,则将utf8视为ANSIC 字符集来解码、转码为unicode【宽字符集】,自然翻车妥妥的
//不过好在fstream接受直接输入的 unicode【宽字符集】编码的输入。即wstring字符串
std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8ToUnicode;
std::wstring unicodePath = utf8ToUnicode.from_bytes(path);
f.open(unicodePath,std::ios::binary);