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?
Asked
Active
Viewed 92 times
0
-
1Have you tried? – tadman Dec 28 '20 at 21:20
-
You can use unicode in character literals with most compilers (if the source file is saved as unicode text), but usually not as symbol names. – πάντα ῥεῖ Dec 28 '20 at 21:55
1 Answers
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
- 380,411
- 33
- 383
- 585