Output unicode symbol π and ≈ in c++ win32 console application

前端 未结 3 514
南旧
南旧 2021-01-03 00:16

I am fairly new to programming, but it seems like the π(pi) symbol is not in the standard set of outputs that ASCII handles.

I am wondering

3条回答
  •  臣服心动
    2021-01-03 00:39

    I'm not really sure about any other methods (such as those that use the STL) but you can do this with Win32 using WriteConsoleW:

    HANDLE hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    LPCWSTR lpPiString = L"\u03C0";
    
    DWORD dwNumberOfCharsWritten;
    WriteConsoleW(hConsoleOutput, lpPiString, 1, &dwNumberOfCharsWritten, NULL);
    

提交回复
热议问题