From 7706e9ba3807f9f31a9310f39f0c8b3007f7fb10 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Wed, 24 Feb 2010 20:13:22 +0100 Subject: fix some 0x10000 codepoint -related issues Merge-request: 480 Reviewed-by: Thiago Macieira --- util/unicode/main.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 70d362d..14d8046 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -2131,15 +2131,14 @@ static QByteArray createCompositionInfo() if (!d.decomposition.isEmpty()) { int utf16Chars = 0; for (int j = 0; j < d.decomposition.size(); ++j) - utf16Chars += d.decomposition.at(j) > 0x10000 ? 2 : 1; + utf16Chars += d.decomposition.at(j) >= 0x10000 ? 2 : 1; decompositions.append(d.decompositionType + (utf16Chars<<8)); for (int j = 0; j < d.decomposition.size(); ++j) { int code = d.decomposition.at(j); - if (code > 0x10000) { + if (code >= 0x10000) { // save as surrogate pair - code -= 0x10000; - ushort high = code/0x400 + 0xd800; - ushort low = code%0x400 + 0xdc00; + ushort high = QChar::highSurrogate(code); + ushort low = QChar::lowSurrogate(code); decompositions.append(high); decompositions.append(low); } else { @@ -2173,15 +2172,14 @@ static QByteArray createCompositionInfo() if (!d.decomposition.isEmpty()) { int utf16Chars = 0; for (int j = 0; j < d.decomposition.size(); ++j) - utf16Chars += d.decomposition.at(j) > 0x10000 ? 2 : 1; + utf16Chars += d.decomposition.at(j) >= 0x10000 ? 2 : 1; decompositions.append(d.decompositionType + (utf16Chars<<8)); for (int j = 0; j < d.decomposition.size(); ++j) { int code = d.decomposition.at(j); - if (code > 0x10000) { + if (code >= 0x10000) { // save as surrogate pair - code -= 0x10000; - ushort high = code/0x400 + 0xd800; - ushort low = code%0x400 + 0xdc00; + ushort high = QChar::highSurrogate(code); + ushort low = QChar::lowSurrogate(code); decompositions.append(high); decompositions.append(low); } else { -- cgit v0.12