How do I print UTF-8 from c++ console application on Windows

This should work:

#include <cstdio>
#include <windows.h>

#pragma execution_character_set( "utf-8" )

int main()
{
    SetConsoleOutputCP( 65001 );
    printf( "Testing unicode -- English -- Ελληνικά -- Español -- Русский. aäbcdefghijklmnoöpqrsßtuüvwxyz\n" );
}

Don’t know if it affects anything, but source file is saved as Unicode (UTF-8 with signature) – Codepage 65001 at FILE -> Advanced Save Options ….

Project -> Properties -> Configuration Properties -> General -> Character Set is set to Use Unicode Character Set.

Some say you need to change console font to Lucida Console, but on my side it is displayed with both Consolas and Lucida Console.

Leave a Comment