Reputation: 125
I'm using a recent version of windows 10. When I tried to run client expample code from boost asio and got an expected exception on this line:
catch (const std::exception& e)
{
std::cerr << e.what() << std::endl;
return 1;
}
It outputs hieroglyphs on console :
connect: ╧юфъы■ўхэшх эх єёЄрэютыхэю, Є.ъ. ъюэхўэ√щ ъюья№■ЄхЁ юЄтхЁу чряЁюё эр яюфъы■ўхэшх
Default codepage of my console is 866 because i'm using russian windows. So then I changed a codepage to 1251 via
chcp 1251
message looks fine:
connect: Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение.
I'm just curious is there any workaround to this without any manipulations with chcp?
Upvotes: 2
Views: 1370
Reputation: 10979
If you want to do it from C++ code then use SetConsoleOutputCP for it.
Upvotes: 2