diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qchar.cpp | 31 | ||||
-rw-r--r-- | src/corelib/tools/qchar.h | 9 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 67ea00d..2f09b0e 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -653,14 +653,41 @@ bool QChar::isSymbol() const \fn bool QChar::isHighSurrogate() const Returns true if the QChar is the high part of a utf16 surrogate - (ie. if its code point is between 0xd800 and 0xdbff). + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). */ /*! \fn bool QChar::isLowSurrogate() const Returns true if the QChar is the low part of a utf16 surrogate - (ie. if its code point is between 0xdc00 and 0xdfff). + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::isHighSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xd800 and 0xdbff, inclusive). +*/ + +/*! + \fn static bool QChar::isLowSurrogate(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + is the high part of a utf16 surrogate + (ie. if its code point is between 0xdc00 and 0xdfff, inclusive). +*/ + +/*! + \fn static bool QChar::requiresSurrogates(uint ucs4) + \since 4.7 + + Returns true if the UCS-4-encoded character specified by \a ucs4 + can be splited to the high and low parts of a utf16 surrogate + (ie. if its code point is greater than or equals to 0x10000). */ /*! diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h index 1432c7f..205f911 100644 --- a/src/corelib/tools/qchar.h +++ b/src/corelib/tools/qchar.h @@ -285,6 +285,15 @@ public: inline void setCell(uchar cell); inline void setRow(uchar row); + static inline bool isHighSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xd800); + } + static inline bool isLowSurrogate(uint ucs4) { + return ((ucs4 & 0xfffffc00) == 0xdc00); + } + static inline bool requiresSurrogates(uint ucs4) { + return (ucs4 >= 0x10000); + } static inline uint surrogateToUcs4(ushort high, ushort low) { return (uint(high)<<10) + low - 0x35fdc00; } |