Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The C++ standard (I noticed it in the new one, but it did already exist in C++03) specifies universal character names, written as \uNNNN and \UNNNNNNNN and representing the characters with unicode codepoints NNNN/NNNNNNNN. This is useful with string literals, especially since explicitly UTF-8, UTF-16 and UCS-4 string literals are also defined. However, the universal character literals are also allowed in identifiers. What is the motivation behind that?

The syntax is obviously totally unreadable, the identifiers may be mangled for the linker and it's not like there was any standard function to retrieve symbols by name anyway. So why would anybody actually use an identifier with universal character literals in it?

Edit: Since it actually existed in C++03 already, additional question would be whether you actually saw a code that used it?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

It allows a system allowing unicode characters in identifier to export the source in a format compilable on any standard conforming compilers. I.E. it is a way to encode unicode over the basic character set (more or less like quoted-printable is used for email, systems who knows better are able to do a better job, other systems are still working).

share|improve this answer

C++ requires that actual extended characters appearing literally in source behave identically with Universal Character Names. Allowing Universal Character Names in identifiers permits programmers to use extended characters in identifiers.

share|improve this answer
It actual extended characters are supported, they have to behave as corresponding universal characters. But they don't have to be supported. –  Jan Hudec Jan 17 '13 at 7:46
That's true but it sort of misses the point, which is that if the committee wants to specify that implementations supporting extended characters should support using those characters in identifiers then that requires UCNs to be allowed in identifiers. I.e. UCNs are allowed in identifiers, not necessarily because that's so readable and everyone loves manually encoding names in hexadecimal, but because if the spec wants to permit extended characters to be used in identifiers then it does so by specifying that UCNs are allowed in identifiers. –  bames53 May 20 at 17:25

Someone may want to create an identifier using a foreign language character that is not enterable on the keyboard or input device. Alternatively, the identifier may contain a character that is not printable using the font or output capabilities of the device but the IDE wants to show an accurate representation.

share|improve this answer
In the first case, the identifier wouldn't look like having that character, so the code would be unreadable and the identifier does not really matter to the machine. And for the second, representation in IDE is a completely separate problem. –  Jan Hudec Sep 26 '12 at 8:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.