I can set the accents with SetConsoleOutputCP(1252)
or locale::global(locale"FR-fr")
, but I can't use it with strings. Seems like it's one or the other. I can output text with accents, or I can output the string with accents, not both. Any ideas?
The code below can be used to reproduce the problem. Simply add locale::global(locale"FR-fr")
or SetConsoleOutputCP(1252)
:
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
string mot;
cout << "Inscrivez un mot avec des accents (é ou è): ";
cin >> mot;
cout << mot;
}
CodePudding user response:
I suggest that you set both the input and output code pages:
SetConsoleCP(1252); // input
SetConsoleOutputCP(1252); // output