[C] How to write Russian characters to Windows console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tested on Windows 7 X86-64 with MinGW-w64 GCC. | |
... | |
#include <windows.h> | |
#include <locale.h> | |
#include <wchar.h> | |
... | |
// Make sure you have Lucida Console or Consolas font installed and choose it as the console font. | |
// Set the specified system locale to 'Russian_Russia.1251'. | |
setlocale(LC_ALL, "Russian"); | |
// Set CP1251 instead of default CP866 to output Cyrillic text. | |
SetConsoleOutputCP(1251); | |
// In most cases the trick should do the job. No warranty though: it's Windows, baby. | |
wprintf(L"Сообщение\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment