How can I output these symbols in c++

前端 未结 2 598
情歌与酒
情歌与酒 2021-01-27 15:32

I want to output this face all I see is question mark symbols

void win(){

        cout << \"░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█\" << endl;
        cout &         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 15:51

    If you are on Windows, the following code works as long as:

    • The console font supports the characters. I'm using Consolas font.
    • The source is compiled from source saved in an encoding that supports the characters. Saving as UTF-8 w/ BOM convinces many Windows applications that a file is UTF-8, but also check your compiler for source encoding options.

    Note the use of wcout and wide strings (L"..."). Also, _setmode is used to alter stdout to support UTF-16 output.

    #include 
    #include 
    #include 
    
    using namespace std;
    
    void win(){
    
        wcout << L"░░░░█▒▒▒▒░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
        wcout << L"░░░░█▒▒▄▀▀▀▀▀▄▄▒▒▒▒▒▒▒▒▒▄▄▀▀▀▀▀▀▄" << endl;
        wcout << L"░░▄▀▒▒▒▄█████▄▒█▒▒▒▒▒▒▒█▒▄█████▄▒█" << endl;
        wcout << L"░█▒▒▒▒▐██▄████▌▒█▒▒▒▒▒█▒▐██▄████▌▒█" << endl;
        wcout << L"▀▒▒▒▒▒▒▀█████▀▒▒█▒░▄▒▄█▒▒▀█████▀▒▒▒█" << endl;
        wcout << L"▒▒▐▒▒▒░░░░▒▒▒▒▒█▒░▒▒▀▒▒█▒▒▒▒▒▒▒▒▒▒▒▒█" << endl;
        wcout << L"▒▌▒▒▒░░░▒▒▒▒▒▄▀▒░▒▄█▄█▄▒▀▄▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
        wcout << L"▒▌▒▒▒▒░▒▒▒▒▒▒▀▄▒▒█▌▌▌▌▌█▄▀▒▒▒▒▒▒▒▒▒▒▒▐" << endl;
        wcout << L"▒▐▒▒▒▒▒▒▒▒▒▒▒▒▒▌▒▒▀███▀▒▌▒▒▒▒▒▒▒▒▒▒▒▒▌" << endl;
        wcout << L"▀▀▄▒▒▒▒▒▒▒▒▒▒▒▌▒▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▒▒█" << endl;
        wcout << L"▀▄▒▀▄▒▒▒▒▒▒▒▒▐▒▒▒▒▒▒▒▒▒▄▄▄▄▒▒▒▒▒▒▄▄▀" << endl;
        wcout << L"▒▒▀▄▒▀▄▀▀▀▄▀▀▀▀▄▄▄▄▄▄▄▀░░░░▀▀▀▀▀▀" << endl;
    }
    
    int main(){
        _setmode(_fileno(stdout), _O_U16TEXT);
        win();
        return 0;
    }
    

    Output:

提交回复
热议问题