1

This code:

void ascii_es() {
    std::vector<int> list;
    std::wstring a;

    list.push_back( 160 );
    list.push_back( 181 );
    list.push_back( 130 );
    list.push_back( 144 );
    list.push_back( 161 );
    list.push_back( 214 );
    list.push_back( 162 );
    list.push_back( 224 );
    list.push_back( 168 );
    list.push_back( 164 );
    list.push_back( 165 );
    list.push_back( 163 );
    list.push_back( 233 );
    for(auto i : list) {
        a = i;
        wcout << L"Alt + " << i << L": " << a << std::endl;
    }
}

nicely displays all Spanish letters on my Win10 console, but this code

void DisplayEs() {
    std::locale myLoc;

    std::locale es("ES");
    std::locale::global(es);
    std::wcout.imbue(es);

    std::wcout << L"Has escogido Espa" << static_cast<char>(164) << "ol" << std::endl;

    std::locale::global(myLoc);
    std::wcout.imbue(myLoc);
}

does not display the letter ñ (Alt+164) at all.

My question is, why my VC++-12 program works perfectly in the first example, but in the second does not?

The examples are two functions in the same program, but they display differently on the Terminal?

Can anybody help?

hotzst
  • 7,238
  • 9
  • 41
  • 64
Papa
  • 41
  • 3

0 Answers0