如何使用 unicode 字符将 TCHAR 转换为 char*。我使用以下代码
//BROWSE FOLDER - Opens a browse folder dialog.
char* browse_folder(void)
{
char *selected_path = NULL;
TCHAR path[MAX_PATH];
BROWSEINFO bi = { 0 };
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl != 0)
{
// get the name of the folder and put it in path
SHGetPathFromIDList(pidl, path);
//Set the current directory to path
SetCurrentDirectory(path);
// free memory used
IMalloc* imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
}
//selected_path = ;
USES_CONVERSION;
selected_path = T2A(path);
}
}
我在 Visual Studio 项目设置中启用了 unicode。我正在使用此功能浏览文件夹,当我将其转换为 char* 时,我在路径(TCHAR)中获得了准确的值* unicode 字符被替换为(?????)符号。