When debugging the accented words deconfigure. How do I correct this? Using Visual Studio.
int main(){
int apples = 50;
cout << "Há"<< apples <<"maçãs."<< endl;
return 0;
}
When debugging the accented words deconfigure. How do I correct this? Using Visual Studio.
int main(){
int apples = 50;
cout << "Há"<< apples <<"maçãs."<< endl;
return 0;
}
Because Windows was made on the basis of gambiarra and so the console uses a different encoding of the Visual Studio interface. If you make a program using GUI you will not have this problem. It also resolves if you encode using a DOS editor.
Because in DOS times, there was no unicode yet. was used the ASCII standard, but it only defines the English alphabet, without accent support. There were, however, ways to extend the number of characters, but each system defined a different encoding, sometimes more than one, like the Portuguese version of DOS that defined accents.
As it was a text-mode system, some characters were reserved for lines, boxes, etc. that could be used to form a simplified interface. When the graphical interfaces became popular, there was no need for symbols for line, boxes and etc, because the GUI gives you this. Soon a new codification was made, which represents practically all western languages. But unfortunately, the codes representing the accents have changed and it is impossible to write a text in DOS and read in GUI without the accents becoming unreadable and vice versa.
MS could have remade the console to use the same coding as the windows, but it was not a good economical option to highlight features for this, as it was focused on promoting graphic applications and was a complicated issue that involved backward compatibility, so they left anyway and DOS was not even considered when the Window joined the unicode.
edit
and you can find Turbo C ++ versions somewhere. chcp 1252
command. For this setting to take effect, the command prompt window should be using a font that supports this encoding (such as "Lucida Console", not "Raster Font") If you decide on option 1, you can know this mapping by compiling and running a simple program like this below:
#include <iostream>
using namespace std;
int main()
{
for(int i = 0x20; i <= 0xff; ++i){
cout << "\x"<< hex << i << "\t=> " << static_cast<char>(i) << endl;
}
return 0;
}
Use:
#include<tchar.h>
Then use:
_tsetlocale(LC_ALL, _T("portuguese"));
From now on you can send cout << "qq coisa com acentos";
that will work!