Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.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++ 为什么';这个简单的程序不行吗?_C++_Visual C++_Unicode - Fatal编程技术网

C++ 为什么';这个简单的程序不行吗?

C++ 为什么';这个简单的程序不行吗?,c++,visual-c++,unicode,C++,Visual C++,Unicode,我正在尝试整理有关Unicode在Windows控制台应用程序中工作方式的所有内容。为什么这个简单的程序不起作用 #include <iostream> int wmain(int argc, const wchar_t* const argv[]) { for (int i = 1; i < argc; ++i) std::wcout << argv[i] << std::endl; return 0; } 该程序

我正在尝试整理有关Unicode在Windows控制台应用程序中工作方式的所有内容。为什么这个简单的程序不起作用

#include <iostream>

int wmain(int argc, const wchar_t* const argv[])
{
    for (int i = 1; i < argc; ++i)
        std::wcout << argv[i] << std::endl;

    return 0;
}
该程序生成

> test.exe 1 2 3 abc абв
1
2
3
abc
第五个论点在哪里?我必须提到,
бббббб
适合我的
GetACP()
getconsoleecp()
代码页(1251866和866)。有趣的是,该程序(在某种程度上)使用这些代码页之外的字符:

> test.exe Sæter
Sцter
但是:


我认为这是因为
wcout
转换为窄字符

有关此主题,请参见


.

如果执行
test.exe 1 2 3 abcаббббб>output.txt
,输出文件是否正确?@Benoit不是,仍然没有最后一行。请尝试以下操作:
printf(“%d\n”,argc)。你得到了什么?那么转换成窄字符有什么特别之处呢<代码>ааааааа
属于我使用的代码页。好的,
std::wcout
确实设置了
badbit
。想知道为什么会发生这种情况,需要进行适当的调查。
> test.exe Sæter
Sцter
> test.exe абв Sæter