Skip to content

Instantly share code, notes, and snippets.

@pkorotkov
Created December 22, 2013 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkorotkov/8087262 to your computer and use it in GitHub Desktop.
Save pkorotkov/8087262 to your computer and use it in GitHub Desktop.
[C] How to write Russian characters to Windows console
// 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