Skip to content

Instantly share code, notes, and snippets.

@DJm00n
Last active November 19, 2019 11:58
Show Gist options
  • Save DJm00n/52797bbc37760ff40b5e4e8926007e6f to your computer and use it in GitHub Desktop.
Save DJm00n/52797bbc37760ff40b5e4e8926007e6f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <Windows.h>
int main()
{
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
std::cout << "GetConsoleCP()=" << GetConsoleCP() << ", GetConsoleOutputCP()=" << GetConsoleOutputCP() << std::endl;
std::cout << "GetACP()=" << GetACP() << std::endl;
CPINFOEX cpInfo;
bool success = GetCPInfoEx(CP_ACP, 0, &cpInfo);
std::cout << "cpInfo.CodePage=" << cpInfo.CodePage << ", cpInfo.CodePageName=" << cpInfo.CodePageName << std::endl;
CHARSETINFO cs;
if (TranslateCharsetInfo((DWORD*)CP_UTF8, &cs, TCI_SRCCODEPAGE))
std::cout << "CHARSETINFO.ciCharset=" << cs.ciCharset << std::endl;
std::cout << "Ну нифигашеньки ж себе! Джва года ждал!!! #悪役適性!!!! 🦄\n";
printf("Даже printf! %s\n", "Ǣ");
// io test
std::string input;
std::cin >> input;
std::cout << "input1:" << input << " size:" << input.size() << std::endl;
std::string input2;
input2.resize(256);
scanf_s("%s", (char*)input2.data(), (unsigned int)input2.size());
std::cout << "input2:" << input2 << " size:" << input2.size() << std::endl;
std::string input3;
input3.resize(256);
DWORD size3 = 0;
ReadConsole(GetStdHandle(STD_INPUT_HANDLE), (char*)input3.data(), (DWORD)input3.size(), &size3, nullptr);
input3.resize(size3);
std::cout << "input3:" << input3 << " size:" << input3.size() << std::endl;
MessageBox(nullptr, u8"Вы предстваляете!? UTF-8! #悪役適性!!!! 🦄", u8"Да вы шо!", MB_ICONQUESTION);
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment