0

I faced the following problem: when I try to save a Cyrillic character in the char16_t variable, I get a c2015 error (too many characters in constant). The most interesting thing is that it happens only when I build with MSVC via cmake. If I do it directly through studio, or build with cmake with another compiler, it's ok. Moreover, in the same case, which does not work with MSVC, it is possible to save Cyrillic characters in wchar_t. I use version 16 of MSVC generator to generate it. Example of broken code:

char16_t val = u'б';

EDIT: It is trouble with utf literals. I`m use this: char16_t val = some_int_val And this work correctly. Also, IDE correctly print int value of literal, but on the compile all crushs.

qwertyui
  • 1
  • 1
  • 1
    Please, add to the question post the **exact error message** you got. – Tsyvarev Sep 27 '22 at 11:20
  • Please [edit] your question to provide a [mcve]. – JosefZ Sep 27 '22 at 11:22
  • The example I attached at the end is no longer working. Even a trivial assignment to a variable doesn't work, although it should – qwertyui Sep 27 '22 at 11:37
  • 1
    Since you are using non-ASCII character in the source code, it is important to check **encoding** of the source **file**. Any modern editor is able to show encoding of the opened file. If the encoding is UTF-8 but without BOM, then make sure you have checked [that question](https://stackoverflow.com/questions/47690822/possible-to-force-cmake-msvc-to-use-utf-8-encoding-for-source-files-without-a-bo). – Tsyvarev Sep 27 '22 at 12:22

0 Answers0