From ba300f42bdbf1e033616ee8a8054d84613b55aca Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 15 May 2012 20:48:20 +0300 Subject: QChar: add isSurrogate() and isNonCharacter() to the public API + QChar::LastValidCodePoint enum value that supercede the UNICODE_LAST_CODEPOINT macro replace uses of hardcoded values with the new API; remove leftovers Change-Id: I1395c9840b85fcb6b08e241b131794a98773c952 Reviewed-by: Thiago Macieira --- src/corelib/tools/qchar.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/corelib/tools/qchar.h') diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 07333c9535..6c423859ec 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -73,7 +73,8 @@ public: ByteOrderMark = 0xfeff, ByteOrderSwapped = 0xfffe, ParagraphSeparator = 0x2029, - LineSeparator = 0x2028 + LineSeparator = 0x2028, + LastValidCodePoint = 0x10ffff }; Q_DECL_CONSTEXPR QChar() : ucs(0) {} @@ -245,24 +246,28 @@ public: inline bool isUpper() const { return QChar::isUpper(ucs); } inline bool isTitleCase() const { return QChar::isTitleCase(ucs); } - inline bool isHighSurrogate() const { - return ((ucs & 0xfc00) == 0xd800); - } - inline bool isLowSurrogate() const { - return ((ucs & 0xfc00) == 0xdc00); - } + inline bool isNonCharacter() const { return QChar::isNonCharacter(ucs); } + inline bool isHighSurrogate() const { return QChar::isHighSurrogate(ucs); } + inline bool isLowSurrogate() const { return QChar::isLowSurrogate(ucs); } + inline bool isSurrogate() const { return QChar::isSurrogate(ucs); } inline uchar cell() const { return uchar(ucs & 0xff); } inline uchar row() const { return uchar((ucs>>8)&0xff); } inline void setCell(uchar cell); inline void setRow(uchar row); + static inline bool isNonCharacter(uint ucs4) { + return ucs4 >= 0xfdd0 && (ucs4 <= 0xfdef || (ucs4 & 0xfffe) == 0xfffe); + } static inline bool isHighSurrogate(uint ucs4) { return ((ucs4 & 0xfffffc00) == 0xd800); } static inline bool isLowSurrogate(uint ucs4) { return ((ucs4 & 0xfffffc00) == 0xdc00); } + static inline bool isSurrogate(uint ucs4) { + return (ucs4 - 0xd800u < 2048u); + } static inline bool requiresSurrogates(uint ucs4) { return (ucs4 >= 0x10000); } -- cgit v1.2.3