#include <string>
#include <vector>
#include <algorithm>
#include <Shlwapi.h>
#pragma comment(lib,"Shlwapi.lib")
using namespace std;
wstring string2wstring(string str)
{
wstring result;
int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
wchar_t* buffer = new wchar_t[len + 1];
MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, buffer, len);
buffer[len] = '\0';
result.append(buffer);
delete[] buffer;
return result;
}
bool cmp(const string& v1, const string& v2)
{
wstring wv1 = string2wstring(v1);
wstring wv2 = string2wstring(v2);
return StrCmpLogicalW(wv1.c_str(), wv2.c_str()) < 0;
}
void main()
{
vector<string> rawFileName;
//添加文件名至rawFileName;
//...
sort(rawFileName.begin(),rawFileName.end(),cmp);
}
C++文件名按逻辑语义排序
最新推荐文章于 2022-07-25 12:07:59 发布