summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorsuzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>2011-09-07 09:58:54 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-09-07 09:58:54 (GMT)
commit50af55095afe1ba048dde357b771485ef2188778 (patch)
treec686d323fdcc1c2f9c64ca3cf6c02f072eb453ee /src/corelib/codecs
parent0f9b98736ceedebece6c9cd4ce2e669300f882c7 (diff)
downloadQt-50af55095afe1ba048dde357b771485ef2188778.zip
Qt-50af55095afe1ba048dde357b771485ef2188778.tar.gz
Qt-50af55095afe1ba048dde357b771485ef2188778.tar.bz2
Replace explicit surrogate handlers by inline methods of QChar class
Merge-request: 1284 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 f59f404..aaebec3 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;