Displaying extended ASCII characters

前端 未结 4 548
孤城傲影
孤城傲影 2020-12-29 00:37

In Visual Studio 2005 on 32-bit Windows, why doesn\'t my console display characters from 128 to 255?

for example:

cout << \"¿\" << endl;          


        
4条回答
  •  长情又很酷
    2020-12-29 00:54

    When you print an ASCII string, Windows internally converts it to UNICODE based on the current code page. There is also a translation from UNICODE to "ASCII" done by the CRT. The following would work.

    #include 
    #include 
    #include 
    #include 
    
    void
    __cdecl
    main(int ac, char **av)
    {
        _setmode(_fileno(stdout), _O_U16TEXT);
        std::wcout  << L"\u00BF";
    }
    

提交回复
热议问题