summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2011-09-07 11:58:54 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-12 16:03:47 +0200
commit560e68e2bd470e2f4d4353b4100729f15efc666f (patch)
tree5947d87316a1bc893dcf6023ab231a1e862d149b /src/corelib/codecs
parent338244e9bfd4d0b8b3bec4b4c1620de71e1d5a7a (diff)
Replace explicit surrogate handlers by inline methods of QChar class
Merge-request: 1284 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> (cherry picked from commit 50af55095afe1ba048dde357b771485ef2188778) Change-Id: I0b1967145ad62243afc2060a6ae4ca141a9609fd Reviewed-on: http://codereview.qt-project.org/4587 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/qutfcodec.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f59f40430a..aaebec3c25 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -90,8 +90,8 @@ QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::Conve
while (ch < end) {
uint u = ch->unicode();
if (surrogate_high >= 0) {
- if (u >= 0xdc00 && u < 0xe000) {
- u = (surrogate_high - 0xd800)*0x400 + (u - 0xdc00) + 0x10000;
+ if (ch->isLowSurrogate()) {
+ u = QChar::surrogateToUcs4(surrogate_high, u);
surrogate_high = -1;
} else {
// high surrogate without low
@@ -101,13 +101,13 @@ QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::Conve
surrogate_high = -1;
continue;
}
- } else if (u >= 0xdc00 && u < 0xe000) {
+ } else if (ch->isLowSurrogate()) {
// low surrogate without high
*cursor = replacement;
++ch;
++invalid;
continue;
- } else if (u >= 0xd800 && u < 0xdc00) {
+ } else if (ch->isHighSurrogate()) {
surrogate_high = u;
++ch;
continue;