summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.h
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-05-15 20:48:20 +0300
committerQt by Nokia <qt-info@nokia.com>2012-05-16 04:24:56 +0200
commitba300f42bdbf1e033616ee8a8054d84613b55aca (patch)
treefc234c8e70cb968c3c7b5729bbeb45519643fb34 /src/corelib/tools/qchar.h
parente8199b599f6c6a438365afb10a00ec8af5ae7243 (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qchar.h')
-rw-r--r--src/corelib/tools/qchar.h19
1 files changed, 12 insertions, 7 deletions
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);
}