|
From: Andy H. <and...@gm...> - 2016-07-21 21:33:23
|
Dear ICU team & users, As a follow-on to the proposal to switch ICU to requiring C++11, this is a proposal to switch the definition of type UChar to be char16_t across all compilers & platforms. It is currently either uint16_t (most platforms) or wchar_t (Windows) ICU ticket #12162 <http://bugs.icu-project.org/trac/ticket/12162> The motivation is both for improved type safety and to allow the convenient use of utf-16 string literals. For example, UnicodeString str(u"¡Hola Mundo!"); In C++11, char16_t is a distinct type that is not compatible with normal integer types. Without redefining UChar, Unicode string literals would not be type-compatible with (const UChar *) interfaces - casting would be required, as in UnicodeString str((const UChar *)u"¡Hola Mundo!"); UChar32 will remain as an int32_t. Using C++11's char32_t is not possible because it is unsigned, while ICU requires that UChar32 be a signed type. For the use of ICU from plain C, the situation is a little more complicated. Currently ICU requires a minimum language level of C99. C11 introduced char16_t (via the standard header uchar.h) and u"text" style string literals. But, support looks looks looks iffy - the header appears to be missing on Mac OSX, and Intel claims not to support it. There has been no proposal or decision as yet to require C11 for use with ICU. So, for now, the definition of ICU's UChar will remain uint16_t in plain C environments. If you have any concerns about this change, please let us know. Thanks, -- Andy |