I
C++ / C#

How to Display Cyrillic in C console if setlocale doesn't work?

How to output Cyrillic to the console, in C? setlocale() doesn't work.
The code:

#include <stdio.h>
#include <locale.h>

int main(int argc, char** argv) {
    setlocale (LC_ALL, "ru");
    printf ("допустим - хелло, ворлд!");
    return 0;
}

Outputs: ╨┤╨╛╨┐╤Г╤Б╤В╨╕╨╝ - ╤Е╨╡╨╗╨╗╨╛, ╨▓╨╛╤А╨╗╨┤!.
Compiler - gcc (MinGW.org GCC Build-20200227-1) 9.2.0.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wisgest, 2020-05-18
@amateurCoder

Either save the source code in the encoding used by the console (probably cp866), or switch the console encoding to the one in which the source code is saved. To edit the source code, use an editor that supports various encodings.

A
Alexey, 2020-05-17
@AlexeyKolodchenko

As far as I know, this format should be:
setlocale(LC_ALL, "ru_RU.UTF-8");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question