Good day. There is a class that changes the console encoding. Code:
#include "stdafx.h" #include <iostream> #include <Windows.h> class edit_locale { int old_cin; int old_cout; public: edit_locale(int); ~edit_locale(); }; int main() { edit_locale(1251); std::cout << "Иван" << std::endl; return 0; } edit_locale::edit_locale(int cp) { this->old_cin = GetConsoleCP(); this->old_cout = GetConsoleOutputCP(); SetConsoleCP(cp); SetConsoleOutputCP(cp); } edit_locale::~edit_locale() { SetConsoleCP(this->old_cin); SetConsoleOutputCP(this->old_cout); } The problem is this: the SetConsole function works only in the constructor; in the main function, no changes occur. And the destructor is not called. With what it can be connected? Thank.