diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-05-03 19:53:23 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-05-03 19:04:25 (GMT) |
commit | 3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647 (patch) | |
tree | de1ed35b10f4433326b614a1ebd732425a0839b5 /src/corelib/tools/qchar.h | |
parent | 7b3092423dc4b6c66aa34c483e6ede2e22747159 (diff) | |
download | Qt-3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647.zip Qt-3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647.tar.gz Qt-3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647.tar.bz2 |
add static QChar::is(High|Low)Surrogate methods
to avoid recoding of character
this also adds QChar::requiresSurrogates() static member
supposed to save from common mistake like `ucs4 > 0x10000`
Merge-request: 606
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'src/corelib/tools/qchar.h')
-rw-r--r-- | src/corelib/tools/qchar.h | 9 |
1 files changed, 9 insertions, 0 deletions
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; } |