转 ifstream 读取中文路径
时间:2010-09-10 来源:涛仔28
感谢互联网。

size_t lengthUnicode = MultiByteToWideChar(CP_ACP, 0, strFileName.c_str(), strFileName.size(), NULL, 0);
if (s_wchar_buf.size() < lengthUnicode + 1)
{
s_wchar_buf.resize(lengthUnicode * 2);
}
wchar_t* szUnicode = &s_wchar_buf[0];
MultiByteToWideChar(CP_ACP, 0, strFileName.c_str(), strFileName.size(), szUnicode, lengthUnicode);
szUnicode[lengthUnicode] = 0;
ifstream ifs(szUnicode, ios::in|ios::ate);
相关阅读 更多 +