I'm trying to sort out everything concerning the way Unicode works in Windows console applications. Why doesn't this simple program work?
#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;
}
Compiled with
>cl /EHsc /D _UNICODE /D UNICODE /Zc:wchar_t test.cpp
the program produces
> test.exe 1 2 3 abc абв
1
2
3
abc
Where is the fifth argument? I have to mention that абв
fits into both my GetACP()
and GetConsoleCP()
& GetConsoleOutputCP()
code pages (1251, 866 & 866). It's interesting that the program works (in a way) with the characters outside of those code pages:
> test.exe Sæter
Sцter
But:
> test.exe абв Sæter