开发者

Support for Universal-Character-Names optional in C++11?

While sifting through the new C++11 spec, I can not find anything that says the support of universal character names is implementation-defined, like devx mentions. I can not find any reference to implementation defined behavior for this. Only 2.14.3.(5) says something about what to write in th开发者_Python百科e executable, but I can not see anything else.

Am I right in assuming that a conforming C++11 compiler will therefore have support for \unnnn and \Unnnnnnnn?


I'm not sure I understand your question fully, but the literal specifiers u and U only serve to specify the integral data type -- nothing is being said about what constitutes a character (or let alone which encoding is presumed). To summarize:

char a1 = 'a', b1[] = "Hello";
wchar_t a2 = L'a', b2[] = L"Hello";
char16_t a3 = u'\u1234', b3[] = u"Hello \uABCD";
char32_t a4 = U'\U5678ABCD', b4[] = U"Hello \U10325476"; // not actually valid codepoints

What you ultimately end up doing with those types is entirely up to you. The literal specifiers L, u and U simply allow you to put literal constants in your code, and they've been around for some time (though I think the u"..." and U"..." string syntax is only official in C++0x, and so are the types char16_t and char32_t, which are genuinely new types, not just aliases).


My understanding is that it is already the case for C++98. It is just that conforming compilers on this point are rare.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜