equal
deleted
inserted
replaced
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2001-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
24 //////////////////////////////////////////////////////////////////////////////////////////// |
24 //////////////////////////////////////////////////////////////////////////////////////////// |
25 // Global functions |
25 // Global functions |
26 //////////////////////////////////////////////////////////////////////////////////////////// |
26 //////////////////////////////////////////////////////////////////////////////////////////// |
27 |
27 |
28 /** |
28 /** |
29 @internalComponent |
|
30 */ |
|
31 TChar UTF16ToChar(const TText16* a) |
|
32 { |
|
33 if (0xD800 <= a[0]) |
|
34 { |
|
35 if (a[0] < 0xE000) |
|
36 { |
|
37 if (a[0] < 0xDC00 && ::IsLowSurrogate(a[1])) |
|
38 { |
|
39 TChar c = ::PairSurrogates(a[0], a[1]); |
|
40 if ((c & 0xFFFE) != 0xFFFE) |
|
41 return c; |
|
42 } |
|
43 return 0xFFFF; |
|
44 } |
|
45 if (a[0] == 0xFFFE) |
|
46 return 0xFFFF; |
|
47 } |
|
48 return a[0]; |
|
49 } |
|
50 |
|
51 /** |
|
52 Is a character a base character (ETrue) or a combiner (EFalse)? |
29 Is a character a base character (ETrue) or a combiner (EFalse)? |
53 For now, we will treat all control characters as base characters. |
30 For now, we will treat all control characters as base characters. |
54 @internalComponent |
31 @internalComponent |
55 */ |
32 */ |
56 TBool IsBaseCharacter(TChar a) |
33 TBool IsBaseCharacter(TChar a) |
150 //////////////////////////////////////////////////////////////////////////////////////////// |
127 //////////////////////////////////////////////////////////////////////////////////////////// |
151 // TUTF32Iterator |
128 // TUTF32Iterator |
152 //////////////////////////////////////////////////////////////////////////////////////////// |
129 //////////////////////////////////////////////////////////////////////////////////////////// |
153 |
130 |
154 /** |
131 /** |
155 @internalComponent |
|
156 */ |
|
157 void TUTF32Iterator::Next() |
|
158 { |
|
159 ASSERT(iStart != iEnd); |
|
160 while (++iStart != iEnd) |
|
161 { |
|
162 iCurrent = ::UTF16ToChar(iStart); |
|
163 if (iCurrent != 0xFFFF) |
|
164 return; |
|
165 } |
|
166 } |
|
167 |
|
168 /** |
|
169 Locates a base character in a string using a folded comparision. Will not find combining |
132 Locates a base character in a string using a folded comparision. Will not find combining |
170 characters, nor will it consider Korean combining Jamo to be equivalent to Hangul. |
133 characters, nor will it consider Korean combining Jamo to be equivalent to Hangul. |
171 @internalComponent |
134 @internalComponent |
172 */ |
135 */ |
173 TBool TUTF32Iterator::LocateFoldedBaseCharacter(TChar aChar) |
136 TBool TUTF32Iterator::LocateFoldedBaseCharacter(TChar aChar) |
202 @internalComponent |
165 @internalComponent |
203 */ |
166 */ |
204 TFoldedDecompIterator::TFoldedDecompIterator(const TUTF32Iterator& a) |
167 TFoldedDecompIterator::TFoldedDecompIterator(const TUTF32Iterator& a) |
205 { |
168 { |
206 Set(a); |
169 Set(a); |
207 } |
|
208 |
|
209 /** |
|
210 @internalComponent |
|
211 */ |
|
212 TBool TFoldedDecompIterator::AtEnd() const |
|
213 { |
|
214 return iOriginal.AtEnd(); |
|
215 } |
170 } |
216 |
171 |
217 /** |
172 /** |
218 @internalComponent |
173 @internalComponent |
219 */ |
174 */ |
277 ASSERT(0 <= index); |
232 ASSERT(0 <= index); |
278 TUTF32Iterator folded = ::GetFoldedDecomposition(index); |
233 TUTF32Iterator folded = ::GetFoldedDecomposition(index); |
279 return folded.Current() != 0x3B9; |
234 return folded.Current() != 0x3B9; |
280 } |
235 } |
281 |
236 |
282 /** |
|
283 @internalComponent |
|
284 */ |
|
285 TChar TFoldedDecompIterator::Current() const |
|
286 { |
|
287 ASSERT(!AtEnd()); |
|
288 return IsInFoldedSequence()? iFolded.Current() : iOriginal.Current(); |
|
289 } |
|
290 |
|
291 /** |
237 /** |
292 Move past this code if it matches unfolded or folded |
238 Move past this code if it matches unfolded or folded |
293 @internalComponent |
239 @internalComponent |
294 */ |
240 */ |
295 TBool TFoldedDecompIterator::Match(TChar aCode) |
241 TBool TFoldedDecompIterator::Match(TChar aCode) |
424 } |
370 } |
425 |
371 |
426 /** |
372 /** |
427 @internalComponent |
373 @internalComponent |
428 */ |
374 */ |
429 TBool TFoldedSortedDecompIterator::AtEnd() const |
|
430 { |
|
431 return iRemaining == 0; |
|
432 } |
|
433 |
|
434 /** |
|
435 @internalComponent |
|
436 */ |
|
437 TChar TFoldedSortedDecompIterator::Current() const |
|
438 { |
|
439 ASSERT(!AtEnd()); |
|
440 return iCurrent.Current(); |
|
441 } |
|
442 |
|
443 /** |
|
444 @internalComponent |
|
445 */ |
|
446 void TFoldedSortedDecompIterator::Next() |
375 void TFoldedSortedDecompIterator::Next() |
447 { |
376 { |
448 ASSERT(!AtEnd()); |
377 ASSERT(!AtEnd()); |
449 --iRemaining; |
378 --iRemaining; |
450 while (++iCurrentCount != iLength) |
379 while (++iCurrentCount != iLength) |
491 if (iBase.Current().GetCombiningClass() != 0 || iBase.CurrentIsBaseFoldedFromCombiner()) |
420 if (iBase.Current().GetCombiningClass() != 0 || iBase.CurrentIsBaseFoldedFromCombiner()) |
492 { |
421 { |
493 iSorted.Set(iBase); |
422 iSorted.Set(iBase); |
494 } |
423 } |
495 } |
424 } |
496 } |
|
497 |
|
498 /** |
|
499 @internalComponent |
|
500 */ |
|
501 TBool TFoldedCanonicalIterator::AtEnd() const |
|
502 { |
|
503 return iSorted.AtEnd() && iBase.AtEnd(); |
|
504 } |
|
505 |
|
506 /** |
|
507 @internalComponent |
|
508 */ |
|
509 TChar TFoldedCanonicalIterator::Current() const |
|
510 { |
|
511 ASSERT(!iBase.AtEnd() || !iSorted.AtEnd()); |
|
512 return iSorted.AtEnd()? iBase.Current() : iSorted.Current(); |
|
513 } |
425 } |
514 |
426 |
515 /** |
427 /** |
516 @internalComponent |
428 @internalComponent |
517 */ |
429 */ |
1142 } |
1054 } |
1143 |
1055 |
1144 /** |
1056 /** |
1145 @internalComponent |
1057 @internalComponent |
1146 */ |
1058 */ |
1147 TBool TDecompositionIterator::AtEnd() const |
|
1148 { |
|
1149 return iBase.AtEnd(); |
|
1150 } |
|
1151 |
|
1152 /** |
|
1153 @internalComponent |
|
1154 */ |
|
1155 TChar TDecompositionIterator::Current() const |
|
1156 { |
|
1157 return iDecomposition.Current(); |
|
1158 } |
|
1159 |
|
1160 /** |
|
1161 @internalComponent |
|
1162 */ |
|
1163 void TDecompositionIterator::Next() |
1059 void TDecompositionIterator::Next() |
1164 { |
1060 { |
1165 ASSERT(!iBase.AtEnd() && !iDecomposition.AtEnd()); |
1061 ASSERT(!iBase.AtEnd() && !iDecomposition.AtEnd()); |
1166 iDecomposition.Next(); |
1062 iDecomposition.Next(); |
1167 if (!iDecomposition.AtEnd()) |
1063 if (!iDecomposition.AtEnd()) |
1242 } |
1138 } |
1243 |
1139 |
1244 /** |
1140 /** |
1245 @internalComponent |
1141 @internalComponent |
1246 */ |
1142 */ |
1247 TBool TCanonicalDecompositionIterator::AtEnd() const |
|
1248 { |
|
1249 return iBase.AtEnd(); |
|
1250 } |
|
1251 |
|
1252 /** |
|
1253 @internalComponent |
|
1254 */ |
|
1255 TChar TCanonicalDecompositionIterator::Current() const |
|
1256 { |
|
1257 return iCurrentCombiningClass? iCurrent.Current() : iBase.Current(); |
|
1258 } |
|
1259 |
|
1260 /** |
|
1261 @internalComponent |
|
1262 */ |
|
1263 void TCanonicalDecompositionIterator::Next() |
1143 void TCanonicalDecompositionIterator::Next() |
1264 { |
1144 { |
1265 iLastPosition = iBase.CurrentPosition(); |
1145 iLastPosition = iBase.CurrentPosition(); |
1266 if (iCurrentCombiningClass == 0) |
1146 if (iCurrentCombiningClass == 0) |
1267 { |
1147 { |
1314 void TCanonicalDecompositionIteratorCached::Set(const TUTF32Iterator& a) |
1194 void TCanonicalDecompositionIteratorCached::Set(const TUTF32Iterator& a) |
1315 { |
1195 { |
1316 iBase.Set(a); |
1196 iBase.Set(a); |
1317 iCacheStart = 0; |
1197 iCacheStart = 0; |
1318 iCacheSize = 0; |
1198 iCacheSize = 0; |
1319 } |
|
1320 |
|
1321 /** |
|
1322 @internalComponent |
|
1323 */ |
|
1324 TBool TCanonicalDecompositionIteratorCached::AtEnd() const |
|
1325 { |
|
1326 return iCacheSize == 0 && iBase.AtEnd(); |
|
1327 } |
1199 } |
1328 |
1200 |
1329 /** |
1201 /** |
1330 @internalComponent |
1202 @internalComponent |
1331 */ |
1203 */ |