diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-05-20 08:46:05 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-05-20 08:46:05 (GMT) |
commit | c98ccc13252aa625f552ae2f05f47e7e5f475aaa (patch) | |
tree | fa17ae12e272b2af341da2854c565514a1442f8b /src | |
parent | 7dd4a5bfc7c1b94b3b4ba72507bd299d4f048a17 (diff) | |
download | Qt-c98ccc13252aa625f552ae2f05f47e7e5f475aaa.zip Qt-c98ccc13252aa625f552ae2f05f47e7e5f475aaa.tar.gz Qt-c98ccc13252aa625f552ae2f05f47e7e5f475aaa.tar.bz2 |
prefer QChar::*surrogate() over hardcoded values
Merge-request: 2393
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 612c492..9e80938 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -939,11 +939,11 @@ int QString::toWCharArray(wchar_t *array) const const unsigned short *uc = utf16(); for (int i = 0; i < length(); ++i) { uint u = uc[i]; - if (u >= 0xd800 && u < 0xdc00 && i < length()-1) { + if (QChar::isHighSurrogate(u) && i + 1 < length()) { ushort low = uc[i+1]; - if (low >= 0xdc00 && low < 0xe000) { + if (QChar::isLowSurrogate(low)) { + u = QChar::surrogateToUcs4(u, low); ++i; - u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; } } *a = wchar_t(u); |