A
A
avion2019-02-24 18:14:23
C++ / C#
avion, 2019-02-24 18:14:23

Cyrillic strings in c++?

Why is the error "character too large for enclosing character literal type" displayed when using Cyrillic, but everything is fine in Latin? Why does Cyrillic take up more space?

#include <iostream>
#include <cstdlib>

using namespace std;

int main() {

    char m[] = {'э', 'м'};

    return 0;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri Esin, 2019-02-24
@avion123678

Because Cyrillic, like all utf-8 in general, takes 2 bytes in memory in most versions of compilers, while Latin takes one byte, which corresponds to the basic numeric type in memory.

N
Nikita Yudin, 2019-02-24
@NikitaNike

setlocale(LC_ALL, "ru");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question