diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-04-12 18:21:39 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-13 10:44:28 +0200 |
commit | 9fd2edb6da5f1f6d644cd7c3f35aebe3e88beee2 (patch) | |
tree | d644aeef68584469ec1b9b6cdbc3d86cc7ddf86b /src/corelib/json | |
parent | b317fe2a606e5b79f24b1e4a1b808f5ff66d3621 (diff) |
replace hardcoded values with a surrogate handling methods
Change-Id: Ib41e08d835f2e8ca2e32b4025c6f5a99840f2e27
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r-- | src/corelib/json/qjsonparser.cpp | 7 | ||||
-rw-r--r-- | src/corelib/json/qjsonwriter.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp index 7d25c81db2..a17426580f 100644 --- a/src/corelib/json/qjsonparser.cpp +++ b/src/corelib/json/qjsonparser.cpp @@ -769,9 +769,10 @@ static inline bool scanUtf8Char(const char *&json, const char *end, uint *result uc = (uc << 6) | (ch & 0x3f); } - if (isUnicodeNonCharacter(uc) || uc >= 0x110000 || - (uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff)) + if (uc < min_uc || isUnicodeNonCharacter(uc) || + (uc >= 0xd800 && uc <= 0xdfff) || uc >= 0x110000) { return false; + } *result = uc; return true; @@ -850,7 +851,7 @@ bool Parser::parseString(bool *latin1) return false; } } - if (ch > 0xffff) { + if (QChar::requiresSurrogates(ch)) { int pos = reserveSpace(4); *(QJsonPrivate::qle_ushort *)(data + pos) = QChar::highSurrogate(ch); *(QJsonPrivate::qle_ushort *)(data + pos + 2) = QChar::lowSurrogate(ch); diff --git a/src/corelib/json/qjsonwriter.cpp b/src/corelib/json/qjsonwriter.cpp index d392bd7529..7cdc3f0dba 100644 --- a/src/corelib/json/qjsonwriter.cpp +++ b/src/corelib/json/qjsonwriter.cpp @@ -160,7 +160,7 @@ static QByteArray escapedString(const QString &s) continue; } - if (u > 0xffff) { + if (QChar::requiresSurrogates(u)) { *cursor++ = 0xf0 | ((uchar) (u >> 18)); *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); } else { |