Popen utf8 path
Popen utf8 path
我想用 _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();
在这条路径上,我得到以下输出:C:WindowsSystem32certutil -hashfile C:UsersVuzeeDesktoptestÄtest.jar
所以我认为问题是因为字符串无法保存 UTF8 字符,那么我该如何解决这个问题并在 popen 中调用它?
对于最后的cout,我得到:
HASH:CertUtil: -hashfile command FAILED: 0x80070003 (WIN32: 3)
CertUtil: The system cannot find the path specified.
您的应用程序可以将字符串存储为 UTF-8,但 Windows 操作系统有两种类型的应用程序接口 — UTF-8 也不是。
您可以使用处理wchar_t
(宽字符(的 _wopen
函数使应用程序正常工作。 首先,您必须将 md5cmd2
中的 string
值转换为宽字符串(转换为 char*
将不起作用(。
延伸阅读:
- 我想将 std::string 转换为常量 wchar_t *
- _popen, _wpopen
相关文章:
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- C ++如何使用UTF8十六进制代码打印UTF8符号?
- C++MySQL连接器没有utf8
- 从/到 UTF-8/UTF-16 的转换需要(例如:utf8 -> 代码点,然后代码点到 utf16)或(例如:utf8 -> utf16)?
- C++和带有国家符号的文件路径(也许用 UTF8 编码)
- 'std::wstring_convert'尽可能多地转换(从 UTF8 文件读取块)
- 如何强制嵌入式python使用与命令行相同的sys.path?
- 将utf16宽std::wstring转换为utf8窄std::string以获得罕见字符时出现问题
- python UnicodeDecodeError: 'utf8' codec 无法解码字节
- MSVC UTF8字符串编码使用了不正确的代码点
- 使用C++将越南语字符从ISO88591、UTF8、UTF16BE、UTF16LE和UTF16编码为十六进制,反之亦然
- 如何使 std::正则表达式匹配 Utf8
- 有没有非utf8字符这样的东西
- VS2019编译器将没有BOM文件的UTF8错误解释为ANSI
- Arduino在通过Serial读取utf8时表现奇怪
- [LLVM-9 clang-9 OSX]: std::filesystem::path unrecognized
- 如何在utf8中获得代码点文字
- 在 C++ 中将 utf8 wstring 转换为窗口中的字符串
- 检查是否需要 utf8 转换并转换为 utf8
- Popen utf8 path