【发布时间】:2016-05-06 18:15:52
【问题描述】:
我正在使用 Visual Studio 2013 开发一个简单的 console 应用程序
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring name;
std::wcout << L"Enter your name: ";
std::wcin >> name;
std::wcout << L"Hello, " << name << std::endl;
system("pause");
return 0;
}
如果我输入Ángel,应用程序运行良好,输出为
Hello, Ángel
问题是如果我在上面放一个断点
std::wcout << L"Hello, " << name << std::endl;
Visual Studio 调试器显示
+ name L"µngel" std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >
虽然控制台中的输出在程序的其他部分是正确的,但我调用了 win32api 函数 CopyFileW() 并且它总是失败,因为路径有 substring Ángel 和substring 传递给函数被转换为µngel
【问题讨论】:
-
我认为您需要更改源文件的编码,我认为类似于 utf-16。
-
问题在于命令提示符使用不同于 Win32 API 的编码。这个问题的答案有帮助吗? stackoverflow.com/questions/15826188/…