Read and follow UTF-8 Everywhere; even Microsoft encourages all Windows users (and developers) in using UTF-8
code pages in Windows apps:
Use UTF-8
character encoding for optimal compatibility between
web apps and other *nix-based platforms (Unix, Linux, and variants),
minimize localization bugs, and reduce testing overhead.
UTF-8
is the universal code page for internationalization and is
able to encode the entire Unicode character set. It is used
pervasively on the web, and is the default for *nix-based platforms.
Following above references, I've created an empty console application from scratch (in Microsoft Visual Studio 19), ending up in the following code (saved as UTF-8
encoded .cpp
file):
#include <windows.h>
#include <iostream>
#pragma execution_character_set( "utf-8" )
int main(int argc, char* argv[])
{
// SetConsoleOutputCP(65001);
// SetConsoleCP(CP_UTF8);
std::cout << ">> Ελληνικά Русский Češtinář" << std::endl;
std::cout << ">> Připojení k serveru úspěšné" << std::endl;
for (int i = 1; i < argc; ++i)
{
printf("param %d = %s\n", i, argv[i]);
}
return 0;
}
Project properties, C/C++ command line parameters (debug configuration):
/JMC /permissive- /ifcOutput "x64\Debug\" /GS /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"x64\Debug\vc142.pdb" /Zc:inline /fp:precise /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /MDd /FC /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\So76656796.pch" /diagnostics:column
Output shows that all strings (either hard-coded, or those passed as command line parameters, are treated properly):
So76656796.exe Ελληνικά Русский Češtinář
>> Ελληνικά Русский Češtinář
>> Připojení k serveru úspěšné
param 1 = Ελληνικά
param 2 = Русский
param 3 = Češtinář
param 4 =