0

I created C++ project with Visual Studio 2019, which prints russian and armenian characters. But in command line prints ?

Source.cpp

#include <iostream>
using namespace std;

int main() {
    setlocale(LC_ALL, "ru");
    cout << "\u053e абв";
    return 0;
}

Output

? ???

In editor too

When I used UTF-8 it outputs this

╨░╨▒╨▓

When I add codepage 20861 displaying ? 6 times

AKK
  • 44
  • 4
  • 1
    Even though you set your program's locale, your C++ compiler is still generating (likely) UTF-8 sequences. Your terminal console is also likely using a different codepage (likely UTF-8) too. Your editor is simply confused. i18n is hard. – Sam Varshavchik Jun 01 '21 at 12:02
  • Using std::wcout << L"\u053e абв\n"; makes the editor show the string correctly. Though the output is still not as desired. It works perfectly on Linux '). – Henry Le Berre Jun 01 '21 at 12:06
  • Try to add ```SetConsoleOutputCP(1251); SetConsoleCP(1251);``` at the beggining – Deumaudit Jun 01 '21 at 12:49
  • It gives 11 errors – AKK Jun 01 '21 at 13:26
  • the source code must be the same code page as in the code page you're setting. But stop doing that and just [use UTF-8 instead](https://stackoverflow.com/a/63454192/995714) – phuclv Jun 02 '21 at 07:10

1 Answers1

1

I suggest you could try to use the Code Page Identifiers

As the following code:

setlocale(LC_ALL, "20866");

enter image description here

Jeaninez - MSFT
  • 3,210
  • 1
  • 5
  • 20