Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Popen utf8路径_C++_Gcc_Utf 8 - Fatal编程技术网

C++ Popen utf8路径

C++ Popen utf8路径,c++,gcc,utf-8,C++,Gcc,Utf 8,当我想用\u popen打开一个utf8路径时,我遇到了一个问题 这是我的代码: char buf1520[1500]; string testme; const char * sroot2 = getenv ("systemroot"); string md5cmd2 = sroot2; md5cmd2 += "\\System32\\certutil -hashfile "; md5cmd2 += "C:\\Users\\Vuzee\\Desktop\\testč\\test.jar"; c

当我想用\u popen打开一个utf8路径时,我遇到了一个问题

这是我的代码:

char buf1520[1500];
string testme;
const char * sroot2 = getenv ("systemroot");
string md5cmd2 = sroot2;
md5cmd2 += "\\System32\\certutil -hashfile ";
md5cmd2 += "C:\\Users\\Vuzee\\Desktop\\testč\\test.jar";
cout << md5cmd2 << endl;
md5cmd2 += " MD5";
const char* md5cmdnovo2 = md5cmd2.c_str();
FILE *p1502 = _popen(md5cmdnovo2, "r");

for (size_t count; (count = fread(buf1520, 1, sizeof(buf1520), p1502));)
    testme += string(buf1520, buf1520 + count);
    _pclose(p1502);

cout << "HASH:" << testme << endl;
cin.ignore();

您的应用程序可以将字符串存储为UTF-8,但Windows操作系统有两种应用程序接口-都不是UTF-8

您可以使用处理
wchar\u t
(宽字符)的函数使应用程序正常工作。首先,您必须将
md5cmd2
中的
string
值转换为宽字符串(转换为
char*
将不起作用)

进一步阅读:


是什么让您认为UTF-8应该在Windows API中工作?在进行文件系统调用之前,您需要将UTF-8转换为UTF-16 LE。
HASH:CertUtil: -hashfile command FAILED: 0x80070003 (WIN32: 3)
CertUtil: The system cannot find the path specified.