From c98ccc13252aa625f552ae2f05f47e7e5f475aaa Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 20 May 2010 10:46:05 +0200 Subject: prefer QChar::*surrogate() over hardcoded values Merge-request: 2393 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstring.cpp | 6 +++--- 1 file 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); -- cgit v0.12