0

So far I knew that in C++ identifiers can only contain letters of English ABC, numbers and underscores, but I am reading the standard and cppreference.com, and they write that unicode characters and special characters can be used as well. Is it true? Or is it true for some compilers only?

https://timsong-cpp.github.io/cppwp/lex.name

https://en.cppreference.com/w/cpp/language/identifiers

christo
  • 19
  • 2

1 Answers1

1

According to translation phase 1, the compiler can map each "character" in a source file to either a character in the basic source character set, or to an escaped Unicode character.

How this mapping is performed, or how the escaped Unicode character is handled, is implementation defined. I.e. it's up to the compiler implementation to handle Unicode characters or not. Some do, some don't. You must read the documentation for your compiler to learn what it does. And if you use Unicode characters in your source, you need to be aware of that they might not work reliably (or at all) if the source is used by other compilers.

In summary. If you want to write portable code, then only use the basic source character set.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621