0

I have some strange and stupid situation. I have this part of code:

FString x = TEXT("ааааааа");//Russian language (line 54)
Caesar* ciph = new Caesar;// (line 55)

When I try to compile my project, I have such errors:

../Widget_Manager.cpp(54): error C2001: newline in constant

../Widget_Manager.cpp(55): error C2146: syntax error: missing ';' before identifier 'Caesar'

The most interesting thing (for me at least) that if I change 54 line on:

FString x = TEXT("абвгдеё");//Russian language (line 54)

or

FString x = TEXT("abcdefg");//English language (line 54)

or if I delete 1 'a' from Russian "ааааааа". It's compile.

Also I try hitting the keyboard in different ways, and I found other uncompiled letter combinations on Russian like: риорыва and нкешшур.

It's work similary without TEXT() macros.

As I understand Russian language contains, beginning with UTF-16. FStrigs is UTF-16. The only thing with which I can associate the behavior of the compiler is that (as far as I know) by default it works in the UTF-8 (whatever that means).

I would be glad if someone understand and can explain me what's going on.

I work in Visual Studio 2019, UE 4.26.1.

////////////////////////////////////////////////

Afterword:

Problem was solved, but question: "Why some of Russian letter combination are compiled encoding while other combination are not compiled (on Cyrillic windows 1251)?" still remains.

Boloto
  • 45
  • 1
  • 8
  • 2
    What encoding is your source file (multibyte, UTF-8, UTF-16, UCS-2)? If it is UTF, does it have a byte order mark? UTF-8 is completely capable of storing any character defined by Unicode -- using Cyrillic does not by any means require you to use UTF-16. – Ben Voigt Mar 08 '21 at 20:33
  • 1
    Save your file as UTF-8 and add the `/utf-8` compiler flag. – Guillaume Racicot Mar 08 '21 at 20:39
  • 1
    fyi https://stackoverflow.com/questions/3768363/character-sets-not-clear – Richard Critten Mar 08 '21 at 20:54
  • @Guillaume It's defenetly due to encoding save option, by default files were saved as Cyrillic (1251) (although my console projects were saved with UTF-8). I discovered that UE was in Russian (my VS-2019 in English), but when i change those settings and create new project it save VS files similary with Cyrillic (1251). – Boloto Mar 09 '21 at 08:59
  • Thanks for help and information to all of you (I cant tag more then 1 person), my immediate compilation problem was solved, but I still have some open questions, maybe I'll ask about them separately – Boloto Mar 09 '21 at 09:07
  • @Boloto yeah I think there's an option to change the default. The only way to keep sanity is to switch to UTF-8, unfortunately. – Guillaume Racicot Mar 09 '21 at 14:48

2 Answers2

0

If you need UTF-16 string laterals, you can use statements like this:

 char16_t str[] = u"Виян Лиже Первомай";

But, of course, it depends on implementation of FString class you use.

Kola73
  • 134
  • 1
  • 7
0

To solve compilation problem, I File -> Save as -> near save button arrow -> Save with encodig -> Choose UTF-8

Boloto
  • 45
  • 1
  • 8