author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 19 | fcece45ef507 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtCore module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
// Don't define it while compiling this module, or USERS of Qt will |
|
43 |
// not be able to link. |
|
44 |
#ifdef QT_NO_CAST_FROM_ASCII |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
45 |
# undef QT_NO_CAST_FROM_ASCII |
0 | 46 |
#endif |
47 |
#ifdef QT_NO_CAST_TO_ASCII |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
48 |
# undef QT_NO_CAST_TO_ASCII |
0 | 49 |
#endif |
50 |
#include "qchar.h" |
|
51 |
#include "qdatastream.h" |
|
52 |
#include "qtextcodec.h" |
|
53 |
||
54 |
#include "qunicodetables_p.h" |
|
55 |
||
56 |
#include "qunicodetables.cpp" |
|
57 |
||
58 |
QT_BEGIN_NAMESPACE |
|
59 |
||
60 |
#ifndef QT_NO_CODEC_FOR_C_STRINGS |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
61 |
# ifdef QT_NO_TEXTCODEC |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
62 |
# define QT_NO_CODEC_FOR_C_STRINGS |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
63 |
# endif |
0 | 64 |
#endif |
65 |
||
66 |
#define FLAG(x) (1 << (x)) |
|
67 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
68 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
69 |
\class QLatin1Char |
0 | 70 |
\brief The QLatin1Char class provides an 8-bit ASCII/Latin-1 character. |
71 |
||
72 |
\ingroup string-processing |
|
73 |
||
74 |
This class is only useful to avoid the codec for C strings business |
|
75 |
in the QChar(ch) constructor. You can avoid it by writing |
|
76 |
QChar(ch, 0). |
|
77 |
||
78 |
\sa QChar, QLatin1String, QString |
|
79 |
*/ |
|
80 |
||
81 |
/*! |
|
82 |
\fn const char QLatin1Char::toLatin1() const |
|
83 |
||
84 |
Converts a Latin-1 character to an 8-bit ASCII representation of |
|
85 |
the character. |
|
86 |
*/ |
|
87 |
||
88 |
/*! |
|
89 |
\fn const ushort QLatin1Char::unicode() const |
|
90 |
||
91 |
Converts a Latin-1 character to an 16-bit-encoded Unicode representation |
|
92 |
of the character. |
|
93 |
*/ |
|
94 |
||
95 |
/*! |
|
96 |
\fn QLatin1Char::QLatin1Char(char c) |
|
97 |
||
98 |
Constructs a Latin-1 character for \a c. This constructor should be |
|
99 |
used when the encoding of the input character is known to be Latin-1. |
|
100 |
*/ |
|
101 |
||
102 |
/*! |
|
103 |
\class QChar |
|
104 |
\brief The QChar class provides a 16-bit Unicode character. |
|
105 |
||
106 |
\ingroup string-processing |
|
107 |
\reentrant |
|
108 |
||
109 |
In Qt, Unicode characters are 16-bit entities without any markup |
|
110 |
or structure. This class represents such an entity. It is |
|
111 |
lightweight, so it can be used everywhere. Most compilers treat |
|
112 |
it like a \c{unsigned short}. |
|
113 |
||
114 |
QChar provides a full complement of testing/classification |
|
115 |
functions, converting to and from other formats, converting from |
|
116 |
composed to decomposed Unicode, and trying to compare and |
|
117 |
case-convert if you ask it to. |
|
118 |
||
119 |
The classification functions include functions like those in the |
|
120 |
standard C++ header \<cctype\> (formerly \<ctype.h\>), but |
|
121 |
operating on the full range of Unicode characters. They all |
|
122 |
return true if the character is a certain type of character; |
|
123 |
otherwise they return false. These classification functions are |
|
124 |
isNull() (returns true if the character is '\\0'), isPrint() |
|
125 |
(true if the character is any sort of printable character, |
|
126 |
including whitespace), isPunct() (any sort of punctation), |
|
127 |
isMark() (Unicode Mark), isLetter() (a letter), isNumber() (any |
|
128 |
sort of numeric character, not just 0-9), isLetterOrNumber(), and |
|
129 |
isDigit() (decimal digits). All of these are wrappers around |
|
130 |
category() which return the Unicode-defined category of each |
|
131 |
character. |
|
132 |
||
133 |
QChar also provides direction(), which indicates the "natural" |
|
134 |
writing direction of this character. The joining() function |
|
135 |
indicates how the character joins with its neighbors (needed |
|
136 |
mostly for Arabic) and finally hasMirrored(), which indicates |
|
137 |
whether the character needs to be mirrored when it is printed in |
|
138 |
its "unnatural" writing direction. |
|
139 |
||
140 |
Composed Unicode characters (like \aring) can be converted to |
|
141 |
decomposed Unicode ("a" followed by "ring above") by using |
|
142 |
decomposition(). |
|
143 |
||
144 |
In Unicode, comparison is not necessarily possible and case |
|
145 |
conversion is very difficult at best. Unicode, covering the |
|
146 |
"entire" world, also includes most of the world's case and |
|
147 |
sorting problems. operator==() and friends will do comparison |
|
148 |
based purely on the numeric Unicode value (code point) of the |
|
149 |
characters, and toUpper() and toLower() will do case changes when |
|
150 |
the character has a well-defined uppercase/lowercase equivalent. |
|
151 |
For locale-dependent comparisons, use |
|
152 |
QString::localeAwareCompare(). |
|
153 |
||
154 |
The conversion functions include unicode() (to a scalar), |
|
155 |
toLatin1() (to scalar, but converts all non-Latin-1 characters to |
|
156 |
0), row() (gives the Unicode row), cell() (gives the Unicode |
|
157 |
cell), digitValue() (gives the integer value of any of the |
|
158 |
numerous digit characters), and a host of constructors. |
|
159 |
||
160 |
QChar provides constructors and cast operators that make it easy |
|
161 |
to convert to and from traditional 8-bit \c{char}s. If you |
|
162 |
defined \c QT_NO_CAST_FROM_ASCII and \c QT_NO_CAST_TO_ASCII, as |
|
163 |
explained in the QString documentation, you will need to |
|
164 |
explicitly call fromAscii() or fromLatin1(), or use QLatin1Char, |
|
165 |
to construct a QChar from an 8-bit \c char, and you will need to |
|
166 |
call toAscii() or toLatin1() to get the 8-bit value back. |
|
167 |
||
168 |
\sa QString, Unicode, QLatin1Char |
|
169 |
*/ |
|
170 |
||
171 |
/*! |
|
172 |
\enum QChar::UnicodeVersion |
|
173 |
||
174 |
Specifies which version of the \l{http://www.unicode.org/}{Unicode standard} |
|
175 |
introduced a certain character. |
|
176 |
||
177 |
\value Unicode_1_1 Version 1.1 |
|
178 |
\value Unicode_2_0 Version 2.0 |
|
179 |
\value Unicode_2_1_2 Version 2.1.2 |
|
180 |
\value Unicode_3_0 Version 3.0 |
|
181 |
\value Unicode_3_1 Version 3.1 |
|
182 |
\value Unicode_3_2 Version 3.2 |
|
183 |
\value Unicode_4_0 Version 4.0 |
|
184 |
\value Unicode_4_1 Version 4.1 |
|
185 |
\value Unicode_5_0 Version 5.0 |
|
186 |
\value Unicode_Unassigned The value is not assigned to any character |
|
187 |
in version 5.0 of Unicode. |
|
188 |
||
189 |
\sa unicodeVersion() |
|
190 |
*/ |
|
191 |
||
192 |
/*! |
|
193 |
\enum QChar::Category |
|
194 |
||
195 |
This enum maps the Unicode character categories. |
|
196 |
||
197 |
The following characters are normative in Unicode: |
|
198 |
||
199 |
\value Mark_NonSpacing Unicode class name Mn |
|
200 |
||
201 |
\value Mark_SpacingCombining Unicode class name Mc |
|
202 |
||
203 |
\value Mark_Enclosing Unicode class name Me |
|
204 |
||
205 |
\value Number_DecimalDigit Unicode class name Nd |
|
206 |
||
207 |
\value Number_Letter Unicode class name Nl |
|
208 |
||
209 |
\value Number_Other Unicode class name No |
|
210 |
||
211 |
\value Separator_Space Unicode class name Zs |
|
212 |
||
213 |
\value Separator_Line Unicode class name Zl |
|
214 |
||
215 |
\value Separator_Paragraph Unicode class name Zp |
|
216 |
||
217 |
\value Other_Control Unicode class name Cc |
|
218 |
||
219 |
\value Other_Format Unicode class name Cf |
|
220 |
||
221 |
\value Other_Surrogate Unicode class name Cs |
|
222 |
||
223 |
\value Other_PrivateUse Unicode class name Co |
|
224 |
||
225 |
\value Other_NotAssigned Unicode class name Cn |
|
226 |
||
227 |
||
228 |
The following categories are informative in Unicode: |
|
229 |
||
230 |
\value Letter_Uppercase Unicode class name Lu |
|
231 |
||
232 |
\value Letter_Lowercase Unicode class name Ll |
|
233 |
||
234 |
\value Letter_Titlecase Unicode class name Lt |
|
235 |
||
236 |
\value Letter_Modifier Unicode class name Lm |
|
237 |
||
238 |
\value Letter_Other Unicode class name Lo |
|
239 |
||
240 |
\value Punctuation_Connector Unicode class name Pc |
|
241 |
||
242 |
\value Punctuation_Dash Unicode class name Pd |
|
243 |
||
244 |
\value Punctuation_Open Unicode class name Ps |
|
245 |
||
246 |
\value Punctuation_Close Unicode class name Pe |
|
247 |
||
248 |
\value Punctuation_InitialQuote Unicode class name Pi |
|
249 |
||
250 |
\value Punctuation_FinalQuote Unicode class name Pf |
|
251 |
||
252 |
\value Punctuation_Other Unicode class name Po |
|
253 |
||
254 |
\value Symbol_Math Unicode class name Sm |
|
255 |
||
256 |
\value Symbol_Currency Unicode class name Sc |
|
257 |
||
258 |
\value Symbol_Modifier Unicode class name Sk |
|
259 |
||
260 |
\value Symbol_Other Unicode class name So |
|
261 |
||
262 |
\value NoCategory Qt cannot find an appropriate category for the character. |
|
263 |
||
264 |
\omitvalue Punctuation_Dask |
|
265 |
||
266 |
\sa category() |
|
267 |
*/ |
|
268 |
||
269 |
/*! |
|
270 |
\enum QChar::Direction |
|
271 |
||
272 |
This enum type defines the Unicode direction attributes. See the |
|
273 |
\l{http://www.unicode.org/}{Unicode Standard} for a description |
|
274 |
of the values. |
|
275 |
||
276 |
In order to conform to C/C++ naming conventions "Dir" is prepended |
|
277 |
to the codes used in the Unicode Standard. |
|
278 |
||
279 |
\value DirAL |
|
280 |
\value DirAN |
|
281 |
\value DirB |
|
282 |
\value DirBN |
|
283 |
\value DirCS |
|
284 |
\value DirEN |
|
285 |
\value DirES |
|
286 |
\value DirET |
|
287 |
\value DirL |
|
288 |
\value DirLRE |
|
289 |
\value DirLRO |
|
290 |
\value DirNSM |
|
291 |
\value DirON |
|
292 |
\value DirPDF |
|
293 |
\value DirR |
|
294 |
\value DirRLE |
|
295 |
\value DirRLO |
|
296 |
\value DirS |
|
297 |
\value DirWS |
|
298 |
||
299 |
\sa direction() |
|
300 |
*/ |
|
301 |
||
302 |
/*! |
|
303 |
\enum QChar::Decomposition |
|
304 |
||
305 |
This enum type defines the Unicode decomposition attributes. See |
|
306 |
the \l{http://www.unicode.org/}{Unicode Standard} for a |
|
307 |
description of the values. |
|
308 |
||
309 |
\value NoDecomposition |
|
310 |
\value Canonical |
|
311 |
\value Circle |
|
312 |
\value Compat |
|
313 |
\value Final |
|
314 |
\value Font |
|
315 |
\value Fraction |
|
316 |
\value Initial |
|
317 |
\value Isolated |
|
318 |
\value Medial |
|
319 |
\value Narrow |
|
320 |
\value NoBreak |
|
321 |
\value Small |
|
322 |
\value Square |
|
323 |
\value Sub |
|
324 |
\value Super |
|
325 |
\value Vertical |
|
326 |
\value Wide |
|
327 |
||
328 |
\omitvalue Single |
|
329 |
||
330 |
\sa decomposition() |
|
331 |
*/ |
|
332 |
||
333 |
/*! |
|
334 |
\enum QChar::Joining |
|
335 |
||
336 |
This enum type defines the Unicode joining attributes. See the |
|
337 |
\l{http://www.unicode.org/}{Unicode Standard} for a description |
|
338 |
of the values. |
|
339 |
||
340 |
\value Center |
|
341 |
\value Dual |
|
342 |
\value OtherJoining |
|
343 |
\value Right |
|
344 |
||
345 |
\sa joining() |
|
346 |
*/ |
|
347 |
||
348 |
/*! |
|
349 |
\enum QChar::CombiningClass |
|
350 |
||
351 |
\internal |
|
352 |
||
353 |
This enum type defines names for some of the Unicode combining |
|
354 |
classes. See the \l{http://www.unicode.org/}{Unicode Standard} |
|
355 |
for a description of the values. |
|
356 |
||
357 |
\value Combining_Above |
|
358 |
\value Combining_AboveAttached |
|
359 |
\value Combining_AboveLeft |
|
360 |
\value Combining_AboveLeftAttached |
|
361 |
\value Combining_AboveRight |
|
362 |
\value Combining_AboveRightAttached |
|
363 |
\value Combining_Below |
|
364 |
\value Combining_BelowAttached |
|
365 |
\value Combining_BelowLeft |
|
366 |
\value Combining_BelowLeftAttached |
|
367 |
\value Combining_BelowRight |
|
368 |
\value Combining_BelowRightAttached |
|
369 |
\value Combining_DoubleAbove |
|
370 |
\value Combining_DoubleBelow |
|
371 |
\value Combining_IotaSubscript |
|
372 |
\value Combining_Left |
|
373 |
\value Combining_LeftAttached |
|
374 |
\value Combining_Right |
|
375 |
\value Combining_RightAttached |
|
376 |
*/ |
|
377 |
||
378 |
/*! |
|
379 |
\enum QChar::SpecialCharacter |
|
380 |
||
381 |
\value Null A QChar with this value isNull(). |
|
382 |
\value Nbsp Non-breaking space. |
|
19
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
383 |
\value ReplacementCharacter The character shown when a font has no glyph |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
384 |
for a certain codepoint. A special question mark character is often |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
385 |
used. Codecs use this codepoint when input data cannot be |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
386 |
represented in Unicode. |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
387 |
\value ObjectReplacementCharacter Used to represent an object such as an |
fcece45ef507
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
388 |
image when such objects cannot be presented. |
0 | 389 |
\value ByteOrderMark |
390 |
\value ByteOrderSwapped |
|
391 |
\value ParagraphSeparator |
|
392 |
\value LineSeparator |
|
393 |
||
394 |
\omitvalue null |
|
395 |
\omitvalue replacement |
|
396 |
\omitvalue byteOrderMark |
|
397 |
\omitvalue byteOrderSwapped |
|
398 |
\omitvalue nbsp |
|
399 |
*/ |
|
400 |
||
401 |
/*! |
|
402 |
\fn void QChar::setCell(uchar cell) |
|
403 |
\internal |
|
404 |
*/ |
|
405 |
||
406 |
/*! |
|
407 |
\fn void QChar::setRow(uchar row) |
|
408 |
\internal |
|
409 |
*/ |
|
410 |
||
411 |
/*! |
|
412 |
\fn QChar::QChar() |
|
413 |
||
414 |
Constructs a null QChar ('\\0'). |
|
415 |
||
416 |
\sa isNull() |
|
417 |
*/ |
|
418 |
||
419 |
/*! |
|
420 |
\fn QChar::QChar(QLatin1Char ch) |
|
421 |
||
422 |
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch. |
|
423 |
*/ |
|
424 |
||
425 |
/*! |
|
426 |
\fn QChar::QChar(SpecialCharacter ch) |
|
427 |
||
428 |
Constructs a QChar for the predefined character value \a ch. |
|
429 |
*/ |
|
430 |
||
431 |
/*! |
|
432 |
Constructs a QChar corresponding to ASCII/Latin-1 character \a |
|
433 |
ch. |
|
434 |
*/ |
|
435 |
QChar::QChar(char ch) |
|
436 |
{ |
|
437 |
#ifndef QT_NO_CODEC_FOR_C_STRINGS |
|
438 |
if (QTextCodec::codecForCStrings()) |
|
439 |
// ##### |
|
440 |
ucs = QTextCodec::codecForCStrings()->toUnicode(&ch, 1).at(0).unicode(); |
|
441 |
else |
|
442 |
#endif |
|
443 |
ucs = uchar(ch); |
|
444 |
} |
|
445 |
||
446 |
/*! |
|
447 |
Constructs a QChar corresponding to ASCII/Latin-1 character \a ch. |
|
448 |
*/ |
|
449 |
QChar::QChar(uchar ch) |
|
450 |
{ |
|
451 |
#ifndef QT_NO_CODEC_FOR_C_STRINGS |
|
452 |
if (QTextCodec::codecForCStrings()) { |
|
453 |
// ##### |
|
454 |
char c = char(ch); |
|
455 |
ucs = QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode(); |
|
456 |
} else |
|
457 |
#endif |
|
458 |
ucs = ch; |
|
459 |
} |
|
460 |
||
461 |
/*! |
|
462 |
\fn QChar::QChar(uchar cell, uchar row) |
|
463 |
||
464 |
Constructs a QChar for Unicode cell \a cell in row \a row. |
|
465 |
||
466 |
\sa cell(), row() |
|
467 |
*/ |
|
468 |
||
469 |
/*! |
|
470 |
\fn QChar::QChar(ushort code) |
|
471 |
||
472 |
Constructs a QChar for the character with Unicode code point \a |
|
473 |
code. |
|
474 |
*/ |
|
475 |
||
476 |
||
477 |
/*! |
|
478 |
\fn QChar::QChar(short code) |
|
479 |
||
480 |
Constructs a QChar for the character with Unicode code point \a |
|
481 |
code. |
|
482 |
*/ |
|
483 |
||
484 |
||
485 |
/*! |
|
486 |
\fn QChar::QChar(uint code) |
|
487 |
||
488 |
Constructs a QChar for the character with Unicode code point \a |
|
489 |
code. |
|
490 |
*/ |
|
491 |
||
492 |
||
493 |
/*! |
|
494 |
\fn QChar::QChar(int code) |
|
495 |
||
496 |
Constructs a QChar for the character with Unicode code point \a |
|
497 |
code. |
|
498 |
*/ |
|
499 |
||
500 |
||
501 |
/*! |
|
502 |
\fn bool QChar::isNull() const |
|
503 |
||
504 |
Returns true if the character is the Unicode character 0x0000 |
|
505 |
('\\0'); otherwise returns false. |
|
506 |
*/ |
|
507 |
||
508 |
/*! |
|
509 |
\fn uchar QChar::cell() const |
|
510 |
||
511 |
Returns the cell (least significant byte) of the Unicode |
|
512 |
character. |
|
513 |
||
514 |
\sa row() |
|
515 |
*/ |
|
516 |
||
517 |
/*! |
|
518 |
\fn uchar QChar::row() const |
|
519 |
||
520 |
Returns the row (most significant byte) of the Unicode character. |
|
521 |
||
522 |
\sa cell() |
|
523 |
*/ |
|
524 |
||
525 |
/*! |
|
526 |
Returns true if the character is a printable character; otherwise |
|
527 |
returns false. This is any character not of category Cc or Cn. |
|
528 |
||
529 |
Note that this gives no indication of whether the character is |
|
530 |
available in a particular font. |
|
531 |
*/ |
|
532 |
bool QChar::isPrint() const |
|
533 |
{ |
|
534 |
const int test = FLAG(Other_Control) | |
|
535 |
FLAG(Other_NotAssigned); |
|
536 |
return !(FLAG(qGetProp(ucs)->category) & test); |
|
537 |
} |
|
538 |
||
539 |
/*! |
|
540 |
Returns true if the character is a separator character |
|
541 |
(Separator_* categories); otherwise returns false. |
|
542 |
*/ |
|
543 |
bool QChar::isSpace() const |
|
544 |
{ |
|
545 |
if(ucs >= 9 && ucs <=13) |
|
546 |
return true; |
|
547 |
const int test = FLAG(Separator_Space) | |
|
548 |
FLAG(Separator_Line) | |
|
549 |
FLAG(Separator_Paragraph); |
|
550 |
return FLAG(qGetProp(ucs)->category) & test; |
|
551 |
} |
|
552 |
||
553 |
/*! |
|
554 |
Returns true if the character is a mark (Mark_* categories); |
|
555 |
otherwise returns false. |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
556 |
|
0 | 557 |
See QChar::Category for more information regarding marks. |
558 |
*/ |
|
559 |
bool QChar::isMark() const |
|
560 |
{ |
|
561 |
const int test = FLAG(Mark_NonSpacing) | |
|
562 |
FLAG(Mark_SpacingCombining) | |
|
563 |
FLAG(Mark_Enclosing); |
|
564 |
return FLAG(qGetProp(ucs)->category) & test; |
|
565 |
} |
|
566 |
||
567 |
/*! |
|
568 |
Returns true if the character is a punctuation mark (Punctuation_* |
|
569 |
categories); otherwise returns false. |
|
570 |
*/ |
|
571 |
bool QChar::isPunct() const |
|
572 |
{ |
|
573 |
const int test = FLAG(Punctuation_Connector) | |
|
574 |
FLAG(Punctuation_Dash) | |
|
575 |
FLAG(Punctuation_Open) | |
|
576 |
FLAG(Punctuation_Close) | |
|
577 |
FLAG(Punctuation_InitialQuote) | |
|
578 |
FLAG(Punctuation_FinalQuote) | |
|
579 |
FLAG(Punctuation_Other); |
|
580 |
return FLAG(qGetProp(ucs)->category) & test; |
|
581 |
} |
|
582 |
||
583 |
/*! |
|
584 |
Returns true if the character is a letter (Letter_* categories); |
|
585 |
otherwise returns false. |
|
586 |
*/ |
|
587 |
bool QChar::isLetter() const |
|
588 |
{ |
|
589 |
const int test = FLAG(Letter_Uppercase) | |
|
590 |
FLAG(Letter_Lowercase) | |
|
591 |
FLAG(Letter_Titlecase) | |
|
592 |
FLAG(Letter_Modifier) | |
|
593 |
FLAG(Letter_Other); |
|
594 |
return FLAG(qGetProp(ucs)->category) & test; |
|
595 |
} |
|
596 |
||
597 |
/*! |
|
598 |
Returns true if the character is a number (Number_* categories, |
|
599 |
not just 0-9); otherwise returns false. |
|
600 |
||
601 |
\sa isDigit() |
|
602 |
*/ |
|
603 |
bool QChar::isNumber() const |
|
604 |
{ |
|
605 |
const int test = FLAG(Number_DecimalDigit) | |
|
606 |
FLAG(Number_Letter) | |
|
607 |
FLAG(Number_Other); |
|
608 |
return FLAG(qGetProp(ucs)->category) & test; |
|
609 |
} |
|
610 |
||
611 |
/*! |
|
612 |
Returns true if the character is a letter or number (Letter_* or |
|
613 |
Number_* categories); otherwise returns false. |
|
614 |
*/ |
|
615 |
bool QChar::isLetterOrNumber() const |
|
616 |
{ |
|
617 |
const int test = FLAG(Letter_Uppercase) | |
|
618 |
FLAG(Letter_Lowercase) | |
|
619 |
FLAG(Letter_Titlecase) | |
|
620 |
FLAG(Letter_Modifier) | |
|
621 |
FLAG(Letter_Other) | |
|
622 |
FLAG(Number_DecimalDigit) | |
|
623 |
FLAG(Number_Letter) | |
|
624 |
FLAG(Number_Other); |
|
625 |
return FLAG(qGetProp(ucs)->category) & test; |
|
626 |
} |
|
627 |
||
628 |
||
629 |
/*! |
|
630 |
Returns true if the character is a decimal digit |
|
631 |
(Number_DecimalDigit); otherwise returns false. |
|
632 |
*/ |
|
633 |
bool QChar::isDigit() const |
|
634 |
{ |
|
635 |
return (qGetProp(ucs)->category == Number_DecimalDigit); |
|
636 |
} |
|
637 |
||
638 |
||
639 |
/*! |
|
640 |
Returns true if the character is a symbol (Symbol_* categories); |
|
641 |
otherwise returns false. |
|
642 |
*/ |
|
643 |
bool QChar::isSymbol() const |
|
644 |
{ |
|
645 |
const int test = FLAG(Symbol_Math) | |
|
646 |
FLAG(Symbol_Currency) | |
|
647 |
FLAG(Symbol_Modifier) | |
|
648 |
FLAG(Symbol_Other); |
|
649 |
return FLAG(qGetProp(ucs)->category) & test; |
|
650 |
} |
|
651 |
||
652 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
653 |
\fn bool QChar::isHighSurrogate() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
654 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
655 |
Returns true if the QChar is the high part of a utf16 surrogate |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
656 |
(ie. if its code point is between 0xd800 and 0xdbff, inclusive). |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
657 |
*/ |
0 | 658 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
659 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
660 |
\fn bool QChar::isLowSurrogate() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
661 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
662 |
Returns true if the QChar is the low part of a utf16 surrogate |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
663 |
(ie. if its code point is between 0xdc00 and 0xdfff, inclusive). |
0 | 664 |
*/ |
665 |
||
666 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
667 |
\fn static bool QChar::isHighSurrogate(uint ucs4) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
668 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
669 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
670 |
Returns true if the UCS-4-encoded character specified by \a ucs4 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
671 |
is the high part of a utf16 surrogate |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
672 |
(ie. if its code point is between 0xd800 and 0xdbff, inclusive). |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
673 |
*/ |
0 | 674 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
675 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
676 |
\fn static bool QChar::isLowSurrogate(uint ucs4) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
677 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
678 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
679 |
Returns true if the UCS-4-encoded character specified by \a ucs4 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
680 |
is the high part of a utf16 surrogate |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
681 |
(ie. if its code point is between 0xdc00 and 0xdfff, inclusive). |
0 | 682 |
*/ |
683 |
||
684 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
685 |
\fn static bool QChar::requiresSurrogates(uint ucs4) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
686 |
\since 4.7 |
0 | 687 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
688 |
Returns true if the UCS-4-encoded character specified by \a ucs4 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
689 |
can be splited to the high and low parts of a utf16 surrogate |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
690 |
(ie. if its code point is greater than or equals to 0x10000). |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
691 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
692 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
693 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
694 |
\fn static uint QChar::surrogateToUcs4(ushort high, ushort low) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
695 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
696 |
Converts a UTF16 surrogate pair with the given \a high and \a low values |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
697 |
to its UCS-4 code point. |
0 | 698 |
*/ |
699 |
||
700 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
701 |
\fn static uint QChar::surrogateToUcs4(QChar high, QChar low) |
0 | 702 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
703 |
Converts a utf16 surrogate pair (\a high, \a low) to its ucs4 code point. |
0 | 704 |
*/ |
705 |
||
706 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
707 |
\fn static ushort QChar::highSurrogate(uint ucs4) |
0 | 708 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
709 |
Returns the high surrogate value of a ucs4 code point. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
710 |
The returned result is undefined if \a ucs4 is smaller than 0x10000. |
0 | 711 |
*/ |
712 |
||
713 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
714 |
\fn static ushort QChar::lowSurrogate(uint ucs4) |
0 | 715 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
716 |
Returns the low surrogate value of a ucs4 code point. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
717 |
The returned result is undefined if \a ucs4 is smaller than 0x10000. |
0 | 718 |
*/ |
719 |
||
720 |
/*! |
|
721 |
Returns the numeric value of the digit, or -1 if the character is |
|
722 |
not a digit. |
|
723 |
*/ |
|
724 |
int QChar::digitValue() const |
|
725 |
{ |
|
726 |
return qGetProp(ucs)->digitValue; |
|
727 |
} |
|
728 |
||
729 |
/*! |
|
730 |
\overload |
|
731 |
Returns the numeric value of the digit, specified by the UCS-2-encoded |
|
732 |
character, \a ucs2, or -1 if the character is not a digit. |
|
733 |
*/ |
|
734 |
int QChar::digitValue(ushort ucs2) |
|
735 |
{ |
|
736 |
return qGetProp(ucs2)->digitValue; |
|
737 |
} |
|
738 |
||
739 |
/*! |
|
740 |
\overload |
|
741 |
Returns the numeric value of the digit specified by the UCS-4-encoded |
|
742 |
character, \a ucs4, or -1 if the character is not a digit. |
|
743 |
*/ |
|
744 |
int QChar::digitValue(uint ucs4) |
|
745 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
746 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 747 |
return 0; |
748 |
return qGetProp(ucs4)->digitValue; |
|
749 |
} |
|
750 |
||
751 |
/*! |
|
752 |
Returns the character's category. |
|
753 |
*/ |
|
754 |
QChar::Category QChar::category() const |
|
755 |
{ |
|
756 |
return (QChar::Category) qGetProp(ucs)->category; |
|
757 |
} |
|
758 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
759 |
/*! |
0 | 760 |
\overload |
761 |
\since 4.3 |
|
762 |
Returns the category of the UCS-4-encoded character specified by \a ucs4. |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
763 |
*/ |
0 | 764 |
QChar::Category QChar::category(uint ucs4) |
765 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
766 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 767 |
return QChar::NoCategory; |
768 |
return (QChar::Category) qGetProp(ucs4)->category; |
|
769 |
} |
|
770 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
771 |
/*! |
0 | 772 |
\overload |
773 |
Returns the category of the UCS-2-encoded character specified by \a ucs2. |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
774 |
*/ |
0 | 775 |
QChar::Category QChar::category(ushort ucs2) |
776 |
{ |
|
777 |
return (QChar::Category) qGetProp(ucs2)->category; |
|
778 |
} |
|
779 |
||
780 |
||
781 |
/*! |
|
782 |
Returns the character's direction. |
|
783 |
*/ |
|
784 |
QChar::Direction QChar::direction() const |
|
785 |
{ |
|
786 |
return (QChar::Direction) qGetProp(ucs)->direction; |
|
787 |
} |
|
788 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
789 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
790 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
791 |
Returns the direction of the UCS-4-encoded character specified by \a ucs4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
792 |
*/ |
0 | 793 |
QChar::Direction QChar::direction(uint ucs4) |
794 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
795 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 796 |
return QChar::DirL; |
797 |
return (QChar::Direction) qGetProp(ucs4)->direction; |
|
798 |
} |
|
799 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
800 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
801 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
802 |
Returns the direction of the UCS-2-encoded character specified by \a ucs2. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
803 |
*/ |
0 | 804 |
QChar::Direction QChar::direction(ushort ucs2) |
805 |
{ |
|
806 |
return (QChar::Direction) qGetProp(ucs2)->direction; |
|
807 |
} |
|
808 |
||
809 |
/*! |
|
810 |
Returns information about the joining properties of the character |
|
811 |
(needed for certain languages such as Arabic). |
|
812 |
*/ |
|
813 |
QChar::Joining QChar::joining() const |
|
814 |
{ |
|
815 |
return (QChar::Joining) qGetProp(ucs)->joining; |
|
816 |
} |
|
817 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
818 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
819 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
820 |
Returns information about the joining properties of the UCS-4-encoded |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
821 |
character specified by \a ucs4 (needed for certain languages such as |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
822 |
Arabic). |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
823 |
*/ |
0 | 824 |
QChar::Joining QChar::joining(uint ucs4) |
825 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
826 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 827 |
return QChar::OtherJoining; |
828 |
return (QChar::Joining) qGetProp(ucs4)->joining; |
|
829 |
} |
|
830 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
831 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
832 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
833 |
Returns information about the joining properties of the UCS-2-encoded |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
834 |
character specified by \a ucs2 (needed for certain languages such as |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
835 |
Arabic). |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
836 |
*/ |
0 | 837 |
QChar::Joining QChar::joining(ushort ucs2) |
838 |
{ |
|
839 |
return (QChar::Joining) qGetProp(ucs2)->joining; |
|
840 |
} |
|
841 |
||
842 |
||
843 |
/*! |
|
844 |
Returns true if the character should be reversed if the text |
|
845 |
direction is reversed; otherwise returns false. |
|
846 |
||
847 |
Same as (ch.mirroredChar() != ch). |
|
848 |
||
849 |
\sa mirroredChar() |
|
850 |
*/ |
|
851 |
bool QChar::hasMirrored() const |
|
852 |
{ |
|
853 |
return qGetProp(ucs)->mirrorDiff != 0; |
|
854 |
} |
|
855 |
||
856 |
/*! |
|
857 |
\fn bool QChar::isLower() const |
|
858 |
||
859 |
Returns true if the character is a lowercase letter, i.e. |
|
860 |
category() is Letter_Lowercase. |
|
861 |
||
862 |
\sa isUpper(), toLower(), toUpper() |
|
863 |
*/ |
|
864 |
||
865 |
/*! |
|
866 |
\fn bool QChar::isUpper() const |
|
867 |
||
868 |
Returns true if the character is an uppercase letter, i.e. |
|
869 |
category() is Letter_Uppercase. |
|
870 |
||
871 |
\sa isLower(), toUpper(), toLower() |
|
872 |
*/ |
|
873 |
||
874 |
/*! |
|
875 |
\fn bool QChar::isTitleCase() const |
|
876 |
\since 4.3 |
|
877 |
||
878 |
Returns true if the character is a titlecase letter, i.e. |
|
879 |
category() is Letter_Titlecase. |
|
880 |
||
881 |
\sa isLower(), toUpper(), toLower(), toTitleCase() |
|
882 |
*/ |
|
883 |
||
884 |
/*! |
|
885 |
Returns the mirrored character if this character is a mirrored |
|
886 |
character; otherwise returns the character itself. |
|
887 |
||
888 |
\sa hasMirrored() |
|
889 |
*/ |
|
890 |
QChar QChar::mirroredChar() const |
|
891 |
{ |
|
892 |
return ucs + qGetProp(ucs)->mirrorDiff; |
|
893 |
} |
|
894 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
895 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
896 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
897 |
Returns the mirrored character if the UCS-4-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
898 |
by \a ucs4 is a mirrored character; otherwise returns the character itself. |
0 | 899 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
900 |
\sa hasMirrored() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
901 |
*/ |
0 | 902 |
uint QChar::mirroredChar(uint ucs4) |
903 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
904 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 905 |
return ucs4; |
906 |
return ucs4 + qGetProp(ucs4)->mirrorDiff; |
|
907 |
} |
|
908 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
909 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
910 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
911 |
Returns the mirrored character if the UCS-2-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
912 |
by \a ucs2 is a mirrored character; otherwise returns the character itself. |
0 | 913 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
914 |
\sa hasMirrored() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
915 |
*/ |
0 | 916 |
ushort QChar::mirroredChar(ushort ucs2) |
917 |
{ |
|
918 |
return ucs2 + qGetProp(ucs2)->mirrorDiff; |
|
919 |
} |
|
920 |
||
921 |
||
922 |
enum { |
|
923 |
Hangul_SBase = 0xac00, |
|
924 |
Hangul_LBase = 0x1100, |
|
925 |
Hangul_VBase = 0x1161, |
|
926 |
Hangul_TBase = 0x11a7, |
|
927 |
Hangul_SCount = 11172, |
|
928 |
Hangul_LCount = 19, |
|
929 |
Hangul_VCount = 21, |
|
930 |
Hangul_TCount = 28, |
|
931 |
Hangul_NCount = 21*28 |
|
932 |
}; |
|
933 |
||
934 |
// buffer has to have a length of 3. It's needed for Hangul decomposition |
|
935 |
static const unsigned short * QT_FASTCALL decompositionHelper |
|
936 |
(uint ucs4, int *length, int *tag, unsigned short *buffer) |
|
937 |
{ |
|
938 |
*length = 0; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
939 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 940 |
return 0; |
941 |
if (ucs4 >= Hangul_SBase && ucs4 < Hangul_SBase + Hangul_SCount) { |
|
942 |
int SIndex = ucs4 - Hangul_SBase; |
|
943 |
buffer[0] = Hangul_LBase + SIndex / Hangul_NCount; // L |
|
944 |
buffer[1] = Hangul_VBase + (SIndex % Hangul_NCount) / Hangul_TCount; // V |
|
945 |
buffer[2] = Hangul_TBase + SIndex % Hangul_TCount; // T |
|
946 |
*length = buffer[2] == Hangul_TBase ? 2 : 3; |
|
947 |
*tag = QChar::Canonical; |
|
948 |
return buffer; |
|
949 |
} |
|
950 |
||
951 |
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4); |
|
952 |
if (index == 0xffff) |
|
953 |
return 0; |
|
954 |
const unsigned short *decomposition = uc_decomposition_map+index; |
|
955 |
*tag = (*decomposition) & 0xff; |
|
956 |
*length = (*decomposition) >> 8; |
|
957 |
return decomposition+1; |
|
958 |
} |
|
959 |
||
960 |
/*! |
|
961 |
Decomposes a character into its parts. Returns an empty string if |
|
962 |
no decomposition exists. |
|
963 |
*/ |
|
964 |
QString QChar::decomposition() const |
|
965 |
{ |
|
966 |
return decomposition(ucs); |
|
967 |
} |
|
968 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
969 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
970 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
971 |
Decomposes the UCS-4-encoded character specified by \a ucs4 into its |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
972 |
constituent parts. Returns an empty string if no decomposition exists. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
973 |
*/ |
0 | 974 |
QString QChar::decomposition(uint ucs4) |
975 |
{ |
|
976 |
unsigned short buffer[3]; |
|
977 |
int length; |
|
978 |
int tag; |
|
979 |
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer); |
|
980 |
return QString::fromUtf16(d, length); |
|
981 |
} |
|
982 |
||
983 |
/*! |
|
984 |
Returns the tag defining the composition of the character. Returns |
|
985 |
QChar::Single if no decomposition exists. |
|
986 |
*/ |
|
987 |
QChar::Decomposition QChar::decompositionTag() const |
|
988 |
{ |
|
989 |
return decompositionTag(ucs); |
|
990 |
} |
|
991 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
992 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
993 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
994 |
Returns the tag defining the composition of the UCS-4-encoded character |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
995 |
specified by \a ucs4. Returns QChar::Single if no decomposition exists. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
996 |
*/ |
0 | 997 |
QChar::Decomposition QChar::decompositionTag(uint ucs4) |
998 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
999 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1000 |
return QChar::NoDecomposition; |
1001 |
const unsigned short index = GET_DECOMPOSITION_INDEX(ucs4); |
|
1002 |
if (index == 0xffff) |
|
1003 |
return QChar::NoDecomposition; |
|
1004 |
return (QChar::Decomposition)(uc_decomposition_map[index] & 0xff); |
|
1005 |
} |
|
1006 |
||
1007 |
/*! |
|
1008 |
Returns the combining class for the character as defined in the |
|
1009 |
Unicode standard. This is mainly useful as a positioning hint for |
|
1010 |
marks attached to a base character. |
|
1011 |
||
1012 |
The Qt text rendering engine uses this information to correctly |
|
1013 |
position non-spacing marks around a base character. |
|
1014 |
*/ |
|
1015 |
unsigned char QChar::combiningClass() const |
|
1016 |
{ |
|
1017 |
return (unsigned char) qGetProp(ucs)->combiningClass; |
|
1018 |
} |
|
1019 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1020 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1021 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1022 |
Returns the combining class for the UCS-4-encoded character specified by |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1023 |
\a ucs4, as defined in the Unicode standard. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1024 |
*/ |
0 | 1025 |
unsigned char QChar::combiningClass(uint ucs4) |
1026 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1027 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1028 |
return 0; |
1029 |
return (unsigned char) qGetProp(ucs4)->combiningClass; |
|
1030 |
} |
|
1031 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1032 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1033 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1034 |
Returns the combining class for the UCS-2-encoded character specified by |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1035 |
\a ucs2, as defined in the Unicode standard. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1036 |
*/ |
0 | 1037 |
unsigned char QChar::combiningClass(ushort ucs2) |
1038 |
{ |
|
1039 |
return (unsigned char) qGetProp(ucs2)->combiningClass; |
|
1040 |
} |
|
1041 |
||
1042 |
/*! |
|
1043 |
Returns the Unicode version that introduced this character. |
|
1044 |
*/ |
|
1045 |
QChar::UnicodeVersion QChar::unicodeVersion() const |
|
1046 |
{ |
|
1047 |
return (QChar::UnicodeVersion) qGetProp(ucs)->unicodeVersion; |
|
1048 |
} |
|
1049 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1050 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1051 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1052 |
Returns the Unicode version that introduced the character specified in |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1053 |
its UCS-4-encoded form as \a ucs4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1054 |
*/ |
0 | 1055 |
QChar::UnicodeVersion QChar::unicodeVersion(uint ucs4) |
1056 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1057 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1058 |
return QChar::Unicode_Unassigned; |
1059 |
return (QChar::UnicodeVersion) qGetProp(ucs4)->unicodeVersion; |
|
1060 |
} |
|
1061 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1062 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1063 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1064 |
Returns the Unicode version that introduced the character specified in |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1065 |
its UCS-2-encoded form as \a ucs2. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1066 |
*/ |
0 | 1067 |
QChar::UnicodeVersion QChar::unicodeVersion(ushort ucs2) |
1068 |
{ |
|
1069 |
return (QChar::UnicodeVersion) qGetProp(ucs2)->unicodeVersion; |
|
1070 |
} |
|
1071 |
||
1072 |
||
1073 |
/*! |
|
1074 |
Returns the lowercase equivalent if the character is uppercase or titlecase; |
|
1075 |
otherwise returns the character itself. |
|
1076 |
*/ |
|
1077 |
QChar QChar::toLower() const |
|
1078 |
{ |
|
1079 |
const QUnicodeTables::Properties *p = qGetProp(ucs); |
|
1080 |
if (!p->lowerCaseSpecial) |
|
1081 |
return ucs + p->lowerCaseDiff; |
|
1082 |
return ucs; |
|
1083 |
} |
|
1084 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1085 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1086 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1087 |
Returns the lowercase equivalent of the UCS-4-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1088 |
by \a ucs4 if the character is uppercase or titlecase; otherwise returns |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1089 |
the character itself. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1090 |
*/ |
0 | 1091 |
uint QChar::toLower(uint ucs4) |
1092 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1093 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1094 |
return ucs4; |
1095 |
const QUnicodeTables::Properties *p = qGetProp(ucs4); |
|
1096 |
if (!p->lowerCaseSpecial) |
|
1097 |
return ucs4 + p->lowerCaseDiff; |
|
1098 |
return ucs4; |
|
1099 |
} |
|
1100 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1101 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1102 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1103 |
Returns the lowercase equivalent of the UCS-2-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1104 |
by \a ucs2 if the character is uppercase or titlecase; otherwise returns |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1105 |
the character itself. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1106 |
*/ |
0 | 1107 |
ushort QChar::toLower(ushort ucs2) |
1108 |
{ |
|
1109 |
const QUnicodeTables::Properties *p = qGetProp(ucs2); |
|
1110 |
if (!p->lowerCaseSpecial) |
|
1111 |
return ucs2 + p->lowerCaseDiff; |
|
1112 |
return ucs2; |
|
1113 |
} |
|
1114 |
||
1115 |
/*! |
|
1116 |
Returns the uppercase equivalent if the character is lowercase or titlecase; |
|
1117 |
otherwise returns the character itself. |
|
1118 |
*/ |
|
1119 |
QChar QChar::toUpper() const |
|
1120 |
{ |
|
1121 |
const QUnicodeTables::Properties *p = qGetProp(ucs); |
|
1122 |
if (!p->upperCaseSpecial) |
|
1123 |
return ucs + p->upperCaseDiff; |
|
1124 |
return ucs; |
|
1125 |
} |
|
1126 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1127 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1128 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1129 |
Returns the uppercase equivalent of the UCS-4-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1130 |
by \a ucs4 if the character is lowercase or titlecase; otherwise returns |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1131 |
the character itself. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1132 |
*/ |
0 | 1133 |
uint QChar::toUpper(uint ucs4) |
1134 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1135 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1136 |
return ucs4; |
1137 |
const QUnicodeTables::Properties *p = qGetProp(ucs4); |
|
1138 |
if (!p->upperCaseSpecial) |
|
1139 |
return ucs4 + p->upperCaseDiff; |
|
1140 |
return ucs4; |
|
1141 |
} |
|
1142 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1143 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1144 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1145 |
Returns the uppercase equivalent of the UCS-2-encoded character specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1146 |
by \a ucs2 if the character is lowercase or titlecase; otherwise returns |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1147 |
the character itself. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1148 |
*/ |
0 | 1149 |
ushort QChar::toUpper(ushort ucs2) |
1150 |
{ |
|
1151 |
const QUnicodeTables::Properties *p = qGetProp(ucs2); |
|
1152 |
if (!p->upperCaseSpecial) |
|
1153 |
return ucs2 + p->upperCaseDiff; |
|
1154 |
return ucs2; |
|
1155 |
} |
|
1156 |
||
1157 |
/*! |
|
1158 |
Returns the title case equivalent if the character is lowercase or uppercase; |
|
1159 |
otherwise returns the character itself. |
|
1160 |
*/ |
|
1161 |
QChar QChar::toTitleCase() const |
|
1162 |
{ |
|
1163 |
const QUnicodeTables::Properties *p = qGetProp(ucs); |
|
1164 |
if (!p->titleCaseSpecial) |
|
1165 |
return ucs + p->titleCaseDiff; |
|
1166 |
return ucs; |
|
1167 |
} |
|
1168 |
||
1169 |
/*! |
|
1170 |
\overload |
|
1171 |
Returns the title case equivalent of the UCS-4-encoded character specified |
|
1172 |
by \a ucs4 if the character is lowercase or uppercase; otherwise returns |
|
1173 |
the character itself. |
|
1174 |
*/ |
|
1175 |
uint QChar::toTitleCase(uint ucs4) |
|
1176 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1177 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1178 |
return ucs4; |
1179 |
const QUnicodeTables::Properties *p = qGetProp(ucs4); |
|
1180 |
if (!p->titleCaseSpecial) |
|
1181 |
return ucs4 + p->titleCaseDiff; |
|
1182 |
return ucs4; |
|
1183 |
} |
|
1184 |
||
1185 |
/*! |
|
1186 |
\overload |
|
1187 |
Returns the title case equivalent of the UCS-2-encoded character specified |
|
1188 |
by \a ucs2 if the character is lowercase or uppercase; otherwise returns |
|
1189 |
the character itself. |
|
1190 |
*/ |
|
1191 |
ushort QChar::toTitleCase(ushort ucs2) |
|
1192 |
{ |
|
1193 |
const QUnicodeTables::Properties *p = qGetProp(ucs2); |
|
1194 |
if (!p->titleCaseSpecial) |
|
1195 |
return ucs2 + p->titleCaseDiff; |
|
1196 |
return ucs2; |
|
1197 |
} |
|
1198 |
||
1199 |
||
1200 |
static inline uint foldCase(const ushort *ch, const ushort *start) |
|
1201 |
{ |
|
1202 |
uint c = *ch; |
|
1203 |
if (QChar(c).isLowSurrogate() && ch > start && QChar(*(ch - 1)).isHighSurrogate()) |
|
1204 |
c = QChar::surrogateToUcs4(*(ch - 1), c); |
|
1205 |
return *ch + qGetProp(c)->caseFoldDiff; |
|
1206 |
} |
|
1207 |
||
1208 |
static inline uint foldCase(uint ch, uint &last) |
|
1209 |
{ |
|
1210 |
uint c = ch; |
|
1211 |
if (QChar(c).isLowSurrogate() && QChar(last).isHighSurrogate()) |
|
1212 |
c = QChar::surrogateToUcs4(last, c); |
|
1213 |
last = ch; |
|
1214 |
return ch + qGetProp(c)->caseFoldDiff; |
|
1215 |
} |
|
1216 |
||
1217 |
static inline ushort foldCase(ushort ch) |
|
1218 |
{ |
|
1219 |
return ch + qGetProp(ch)->caseFoldDiff; |
|
1220 |
} |
|
1221 |
||
1222 |
/*! |
|
1223 |
Returns the case folded equivalent of the character. For most Unicode characters this |
|
1224 |
is the same as toLowerCase(). |
|
1225 |
*/ |
|
1226 |
QChar QChar::toCaseFolded() const |
|
1227 |
{ |
|
1228 |
return ucs + qGetProp(ucs)->caseFoldDiff; |
|
1229 |
} |
|
1230 |
||
1231 |
/*! |
|
1232 |
\overload |
|
1233 |
Returns the case folded equivalent of the UCS-4-encoded character specified |
|
1234 |
by \a ucs4. For most Unicode characters this is the same as toLowerCase(). |
|
1235 |
*/ |
|
1236 |
uint QChar::toCaseFolded(uint ucs4) |
|
1237 |
{ |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1238 |
if (ucs4 > UNICODE_LAST_CODEPOINT) |
0 | 1239 |
return ucs4; |
1240 |
return ucs4 + qGetProp(ucs4)->caseFoldDiff; |
|
1241 |
} |
|
1242 |
||
1243 |
/*! |
|
1244 |
\overload |
|
1245 |
Returns the case folded equivalent of the UCS-2-encoded character specified |
|
1246 |
by \a ucs2. For most Unicode characters this is the same as toLowerCase(). |
|
1247 |
*/ |
|
1248 |
ushort QChar::toCaseFolded(ushort ucs2) |
|
1249 |
{ |
|
1250 |
return ucs2 + qGetProp(ucs2)->caseFoldDiff; |
|
1251 |
} |
|
1252 |
||
1253 |
||
1254 |
/*! |
|
1255 |
\fn char QChar::latin1() const |
|
1256 |
||
1257 |
Use toLatin1() instead. |
|
1258 |
*/ |
|
1259 |
||
1260 |
/*! |
|
1261 |
\fn char QChar::ascii() const |
|
1262 |
||
1263 |
Use toAscii() instead. |
|
1264 |
*/ |
|
1265 |
||
1266 |
/*! |
|
1267 |
\fn char QChar::toLatin1() const |
|
1268 |
||
1269 |
Returns the Latin-1 character equivalent to the QChar, or 0. This |
|
1270 |
is mainly useful for non-internationalized software. |
|
1271 |
||
1272 |
\sa toAscii(), unicode(), QTextCodec::codecForCStrings() |
|
1273 |
*/ |
|
1274 |
||
1275 |
/*! |
|
1276 |
\fn char QChar::toAscii() const |
|
1277 |
Returns the character value of the QChar obtained using the current |
|
1278 |
codec used to read C strings, or 0 if the character is not representable |
|
1279 |
using this codec. The default codec handles Latin-1 encoded text, |
|
1280 |
but this can be changed to assist developers writing source code using |
|
1281 |
other encodings. |
|
1282 |
||
1283 |
The main purpose of this function is to preserve ASCII characters used |
|
1284 |
in C strings. This is mainly useful for developers of non-internationalized |
|
1285 |
software. |
|
1286 |
||
1287 |
\sa toLatin1(), unicode(), QTextCodec::codecForCStrings() |
|
1288 |
*/ |
|
1289 |
#ifdef Q_COMPILER_MANGLES_RETURN_TYPE |
|
1290 |
const char QChar::toAscii() const |
|
1291 |
#else |
|
1292 |
char QChar::toAscii() const |
|
1293 |
#endif |
|
1294 |
{ |
|
1295 |
#ifndef QT_NO_CODEC_FOR_C_STRINGS |
|
1296 |
if (QTextCodec::codecForCStrings()) |
|
1297 |
// ##### |
|
1298 |
return QTextCodec::codecForCStrings()->fromUnicode(QString(*this)).at(0); |
|
1299 |
#endif |
|
1300 |
return ucs > 0xff ? 0 : char(ucs); |
|
1301 |
} |
|
1302 |
||
1303 |
/*! |
|
1304 |
\fn QChar QChar::fromLatin1(char c) |
|
1305 |
||
1306 |
Converts the Latin-1 character \a c to its equivalent QChar. This |
|
1307 |
is mainly useful for non-internationalized software. |
|
1308 |
||
1309 |
\sa fromAscii(), unicode(), QTextCodec::codecForCStrings() |
|
1310 |
*/ |
|
1311 |
||
1312 |
/*! |
|
1313 |
Converts the ASCII character \a c to its equivalent QChar. This |
|
1314 |
is mainly useful for non-internationalized software. |
|
1315 |
||
1316 |
An alternative is to use QLatin1Char. |
|
1317 |
||
1318 |
\sa fromLatin1(), unicode(), QTextCodec::codecForCStrings() |
|
1319 |
*/ |
|
1320 |
QChar QChar::fromAscii(char c) |
|
1321 |
{ |
|
1322 |
#ifndef QT_NO_CODEC_FOR_C_STRINGS |
|
1323 |
if (QTextCodec::codecForCStrings()) |
|
1324 |
// ##### |
|
1325 |
return QTextCodec::codecForCStrings()->toUnicode(&c, 1).at(0).unicode(); |
|
1326 |
#endif |
|
1327 |
return QChar(ushort((uchar)c)); |
|
1328 |
} |
|
1329 |
||
1330 |
#ifndef QT_NO_DATASTREAM |
|
1331 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1332 |
\relates QChar |
0 | 1333 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1334 |
Writes the char \a chr to the stream \a out. |
0 | 1335 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1336 |
\sa {Serializing Qt Data Types} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1337 |
*/ |
0 | 1338 |
QDataStream &operator<<(QDataStream &out, const QChar &chr) |
1339 |
{ |
|
1340 |
out << quint16(chr.unicode()); |
|
1341 |
return out; |
|
1342 |
} |
|
1343 |
||
1344 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1345 |
\relates QChar |
0 | 1346 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1347 |
Reads a char from the stream \a in into char \a chr. |
0 | 1348 |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1349 |
\sa {Serializing Qt Data Types} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1350 |
*/ |
0 | 1351 |
QDataStream &operator>>(QDataStream &in, QChar &chr) |
1352 |
{ |
|
1353 |
quint16 u; |
|
1354 |
in >> u; |
|
1355 |
chr.unicode() = ushort(u); |
|
1356 |
return in; |
|
1357 |
} |
|
1358 |
#endif // QT_NO_DATASTREAM |
|
1359 |
||
1360 |
/*! |
|
1361 |
\fn ushort & QChar::unicode() |
|
1362 |
||
1363 |
Returns a reference to the numeric Unicode value of the QChar. |
|
1364 |
*/ |
|
1365 |
||
1366 |
/*! |
|
1367 |
\fn ushort QChar::unicode() const |
|
1368 |
||
1369 |
\overload |
|
1370 |
*/ |
|
1371 |
||
1372 |
/***************************************************************************** |
|
1373 |
Documentation of QChar related functions |
|
1374 |
*****************************************************************************/ |
|
1375 |
||
1376 |
/*! |
|
1377 |
\fn bool operator==(QChar c1, QChar c2) |
|
1378 |
||
1379 |
\relates QChar |
|
1380 |
||
1381 |
Returns true if \a c1 and \a c2 are the same Unicode character; |
|
1382 |
otherwise returns false. |
|
1383 |
*/ |
|
1384 |
||
1385 |
/*! |
|
1386 |
\fn int operator!=(QChar c1, QChar c2) |
|
1387 |
||
1388 |
\relates QChar |
|
1389 |
||
1390 |
Returns true if \a c1 and \a c2 are not the same Unicode |
|
1391 |
character; otherwise returns false. |
|
1392 |
*/ |
|
1393 |
||
1394 |
/*! |
|
1395 |
\fn int operator<=(QChar c1, QChar c2) |
|
1396 |
||
1397 |
\relates QChar |
|
1398 |
||
1399 |
Returns true if the numeric Unicode value of \a c1 is less than |
|
1400 |
or equal to that of \a c2; otherwise returns false. |
|
1401 |
*/ |
|
1402 |
||
1403 |
/*! |
|
1404 |
\fn int operator>=(QChar c1, QChar c2) |
|
1405 |
||
1406 |
\relates QChar |
|
1407 |
||
1408 |
Returns true if the numeric Unicode value of \a c1 is greater than |
|
1409 |
or equal to that of \a c2; otherwise returns false. |
|
1410 |
*/ |
|
1411 |
||
1412 |
/*! |
|
1413 |
\fn int operator<(QChar c1, QChar c2) |
|
1414 |
||
1415 |
\relates QChar |
|
1416 |
||
1417 |
Returns true if the numeric Unicode value of \a c1 is less than |
|
1418 |
that of \a c2; otherwise returns false. |
|
1419 |
*/ |
|
1420 |
||
1421 |
/*! |
|
1422 |
\fn int operator>(QChar c1, QChar c2) |
|
1423 |
||
1424 |
\relates QChar |
|
1425 |
||
1426 |
Returns true if the numeric Unicode value of \a c1 is greater than |
|
1427 |
that of \a c2; otherwise returns false. |
|
1428 |
*/ |
|
1429 |
||
1430 |
/*! |
|
1431 |
\fn bool QChar::mirrored() const |
|
1432 |
||
1433 |
Use hasMirrored() instead. |
|
1434 |
*/ |
|
1435 |
||
1436 |
/*! |
|
1437 |
\fn QChar QChar::lower() const |
|
1438 |
||
1439 |
Use toLower() instead. |
|
1440 |
*/ |
|
1441 |
||
1442 |
/*! |
|
1443 |
\fn QChar QChar::upper() const |
|
1444 |
||
1445 |
Use toUpper() instead. |
|
1446 |
*/ |
|
1447 |
||
1448 |
/*! |
|
1449 |
\fn bool QChar::networkOrdered() |
|
1450 |
||
1451 |
See if QSysInfo::ByteOrder == QSysInfo::BigEndian instead. |
|
1452 |
*/ |
|
1453 |
||
1454 |
||
1455 |
// --------------------------------------------------------------------------- |
|
1456 |
||
1457 |
||
1458 |
static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion version, int from) |
|
1459 |
{ |
|
1460 |
unsigned short buffer[3]; |
|
1461 |
||
1462 |
QString &s = *str; |
|
1463 |
||
1464 |
const unsigned short *utf16 = reinterpret_cast<unsigned short *>(s.data()); |
|
1465 |
const unsigned short *uc = utf16 + s.length(); |
|
1466 |
while (uc != utf16 + from) { |
|
1467 |
uint ucs4 = *(--uc); |
|
1468 |
if (QChar(ucs4).isLowSurrogate() && uc != utf16) { |
|
1469 |
ushort high = *(uc - 1); |
|
1470 |
if (QChar(high).isHighSurrogate()) { |
|
1471 |
--uc; |
|
1472 |
ucs4 = QChar::surrogateToUcs4(high, ucs4); |
|
1473 |
} |
|
1474 |
} |
|
1475 |
if (QChar::unicodeVersion(ucs4) > version) |
|
1476 |
continue; |
|
1477 |
int length; |
|
1478 |
int tag; |
|
1479 |
const unsigned short *d = decompositionHelper(ucs4, &length, &tag, buffer); |
|
1480 |
if (!d || (canonical && tag != QChar::Canonical)) |
|
1481 |
continue; |
|
1482 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1483 |
int pos = uc - utf16; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1484 |
s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length); |
0 | 1485 |
// since the insert invalidates the pointers and we do decomposition recursive |
1486 |
utf16 = reinterpret_cast<unsigned short *>(s.data()); |
|
1487 |
uc = utf16 + pos + length; |
|
1488 |
} |
|
1489 |
} |
|
1490 |
||
1491 |
||
1492 |
static ushort ligatureHelper(ushort u1, ushort u2) |
|
1493 |
{ |
|
1494 |
// hangul L-V pair |
|
1495 |
int LIndex = u1 - Hangul_LBase; |
|
1496 |
if (0 <= LIndex && LIndex < Hangul_LCount) { |
|
1497 |
int VIndex = u2 - Hangul_VBase; |
|
1498 |
if (0 <= VIndex && VIndex < Hangul_VCount) |
|
1499 |
return Hangul_SBase + (LIndex * Hangul_VCount + VIndex) * Hangul_TCount; |
|
1500 |
} |
|
1501 |
||
1502 |
// hangul LV-T pair |
|
1503 |
int SIndex = u1 - Hangul_SBase; |
|
1504 |
if (0 <= SIndex && SIndex < Hangul_SCount && (SIndex % Hangul_TCount) == 0) { |
|
1505 |
int TIndex = u2 - Hangul_TBase; |
|
1506 |
if (0 <= TIndex && TIndex <= Hangul_TCount) |
|
1507 |
return u1 + TIndex; |
|
1508 |
} |
|
1509 |
||
1510 |
const unsigned short index = GET_LIGATURE_INDEX(u2); |
|
1511 |
if (index == 0xffff) |
|
1512 |
return 0; |
|
1513 |
const unsigned short *ligatures = uc_ligature_map+index; |
|
1514 |
ushort length = *ligatures; |
|
1515 |
++ligatures; |
|
1516 |
// ### use bsearch |
|
1517 |
for (uint i = 0; i < length; ++i) |
|
1518 |
if (ligatures[2*i] == u1) |
|
1519 |
return ligatures[2*i+1]; |
|
1520 |
return 0; |
|
1521 |
} |
|
1522 |
||
1523 |
static void composeHelper(QString *str, int from) |
|
1524 |
{ |
|
1525 |
QString &s = *str; |
|
1526 |
||
1527 |
if (s.length() - from < 2) |
|
1528 |
return; |
|
1529 |
||
1530 |
// the loop can partly ignore high Unicode as all ligatures are in the BMP |
|
1531 |
int starter = 0; |
|
1532 |
int lastCombining = 0; |
|
1533 |
int pos = from; |
|
1534 |
while (pos < s.length()) { |
|
1535 |
uint uc = s.at(pos).unicode(); |
|
1536 |
if (QChar(uc).isHighSurrogate() && pos < s.length()-1) { |
|
1537 |
ushort low = s.at(pos+1).unicode(); |
|
1538 |
if (QChar(low).isLowSurrogate()) { |
|
1539 |
uc = QChar::surrogateToUcs4(uc, low); |
|
1540 |
++pos; |
|
1541 |
} |
|
1542 |
} |
|
1543 |
int combining = QChar::combiningClass(uc); |
|
1544 |
if (starter == pos - 1 || combining > lastCombining) { |
|
1545 |
// allowed to form ligature with S |
|
1546 |
QChar ligature = ligatureHelper(s.at(starter).unicode(), uc); |
|
1547 |
if (ligature.unicode()) { |
|
1548 |
s[starter] = ligature; |
|
1549 |
s.remove(pos, 1); |
|
1550 |
continue; |
|
1551 |
} |
|
1552 |
} |
|
1553 |
if (!combining) |
|
1554 |
starter = pos; |
|
1555 |
lastCombining = combining; |
|
1556 |
++pos; |
|
1557 |
} |
|
1558 |
} |
|
1559 |
||
1560 |
||
1561 |
static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, int from) |
|
1562 |
{ |
|
1563 |
QString &s = *str; |
|
1564 |
const int l = s.length()-1; |
|
1565 |
int pos = from; |
|
1566 |
while (pos < l) { |
|
1567 |
int p2 = pos+1; |
|
1568 |
uint u1 = s.at(pos).unicode(); |
|
1569 |
if (QChar(u1).isHighSurrogate()) { |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1570 |
ushort low = s.at(p2).unicode(); |
0 | 1571 |
if (QChar(low).isLowSurrogate()) { |
1572 |
u1 = QChar::surrogateToUcs4(u1, low); |
|
1573 |
if (p2 >= l) |
|
1574 |
break; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1575 |
++p2; |
0 | 1576 |
} |
1577 |
} |
|
1578 |
uint u2 = s.at(p2).unicode(); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1579 |
if (QChar(u2).isHighSurrogate() && p2 < l) { |
0 | 1580 |
ushort low = s.at(p2+1).unicode(); |
1581 |
if (QChar(low).isLowSurrogate()) { |
|
1582 |
u2 = QChar::surrogateToUcs4(u2, low); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1583 |
++p2; |
0 | 1584 |
} |
1585 |
} |
|
1586 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1587 |
ushort c2 = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1588 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1589 |
const QUnicodeTables::Properties *p = qGetProp(u2); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1590 |
if ((QChar::UnicodeVersion)p->unicodeVersion <= version) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1591 |
c2 = p->combiningClass; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1592 |
} |
0 | 1593 |
if (c2 == 0) { |
1594 |
pos = p2+1; |
|
1595 |
continue; |
|
1596 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1597 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1598 |
ushort c1 = 0; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1599 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1600 |
const QUnicodeTables::Properties *p = qGetProp(u1); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1601 |
if ((QChar::UnicodeVersion)p->unicodeVersion <= version) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1602 |
c1 = p->combiningClass; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1603 |
} |
0 | 1604 |
|
1605 |
if (c1 > c2) { |
|
1606 |
QChar *uc = s.data(); |
|
1607 |
int p = pos; |
|
1608 |
// exchange characters |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1609 |
if (!QChar::requiresSurrogates(u2)) { |
0 | 1610 |
uc[p++] = u2; |
1611 |
} else { |
|
1612 |
uc[p++] = QChar::highSurrogate(u2); |
|
1613 |
uc[p++] = QChar::lowSurrogate(u2); |
|
1614 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1615 |
if (!QChar::requiresSurrogates(u1)) { |
0 | 1616 |
uc[p++] = u1; |
1617 |
} else { |
|
1618 |
uc[p++] = QChar::highSurrogate(u1); |
|
1619 |
uc[p++] = QChar::lowSurrogate(u1); |
|
1620 |
} |
|
1621 |
if (pos > 0) |
|
1622 |
--pos; |
|
1623 |
if (pos > 0 && s.at(pos).isLowSurrogate()) |
|
1624 |
--pos; |
|
1625 |
} else { |
|
1626 |
++pos; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
1627 |
if (QChar::requiresSurrogates(u1)) |
0 | 1628 |
++pos; |
1629 |
} |
|
1630 |
} |
|
1631 |
} |
|
1632 |
||
1633 |
int QT_FASTCALL QUnicodeTables::script(unsigned int uc) |
|
1634 |
{ |
|
1635 |
if (uc > 0xffff) |
|
1636 |
return Common; |
|
1637 |
int script = uc_scripts[uc >> 7]; |
|
1638 |
if (script < ScriptSentinel) |
|
1639 |
return script; |
|
1640 |
script = (((script - ScriptSentinel) * UnicodeBlockSize) + UnicodeBlockCount); |
|
1641 |
script = uc_scripts[script + (uc & 0x7f)]; |
|
1642 |
return script; |
|
1643 |
} |
|
1644 |
||
1645 |
Q_CORE_EXPORT QUnicodeTables::LineBreakClass QT_FASTCALL QUnicodeTables::lineBreakClass(uint ucs4) |
|
1646 |
{ |
|
1647 |
return (QUnicodeTables::LineBreakClass) qGetProp(ucs4)->line_break_class; |
|
1648 |
} |
|
1649 |
||
1650 |
QT_END_NAMESPACE |