|     24  |     24  | 
|     25 // maximum size of string which has its own sort key |     25 // maximum size of string which has its own sort key | 
|     26 // 16 instead of 8, in case all supplementary characters |     26 // 16 instead of 8, in case all supplementary characters | 
|     27 static const TInt KKeyedStringBufferSize = 16; |     27 static const TInt KKeyedStringBufferSize = 16; | 
|     28  |     28  | 
|     29  |         | 
|     30 inline TText16 GetHighSurrogate(TUint aChar) |         | 
|     31 /** |         | 
|     32 Retrieve the high surrogate of a supplementary character. |         | 
|     33  |         | 
|     34 @param aChar The 32-bit code point value of a Unicode character. |         | 
|     35  |         | 
|     36 @return High surrogate of aChar, if aChar is a supplementary character;  |         | 
|     37         aChar itself, if aChar is not a supplementary character. |         | 
|     38 */ |         | 
|     39 	{ |         | 
|     40 	return STATIC_CAST(TText16, 0xD7C0 + (aChar >> 10)); |         | 
|     41 	} |         | 
|     42  |         | 
|     43 inline TText16 GetLowSurrogate(TUint aChar) |         | 
|     44 /** |         | 
|     45 Retrieve the low surrogate of a supplementary character. |         | 
|     46  |         | 
|     47 @param aChar The 32-bit code point value of a Unicode character. |         | 
|     48  |         | 
|     49 @return Low surrogate of aChar, if aChar is a supplementary character;  |         | 
|     50         zero, if aChar is not a supplementary character. |         | 
|     51 */ |         | 
|     52 	{ |         | 
|     53 	return STATIC_CAST(TText16, 0xDC00 | (aChar & 0x3FF)); |         | 
|     54 	} |         | 
|     55  |         | 
|     56 inline TUint JoinSurrogate(TText16 aHighSurrogate, TText16 aLowSurrogate) |         | 
|     57 /** |         | 
|     58 Combine a high surrogate and a low surrogate into a supplementary character. |         | 
|     59  |         | 
|     60 @return The 32-bit code point value of the generated Unicode supplementary |         | 
|     61         character. |         | 
|     62 */ |         | 
|     63 	{ |         | 
|     64 	return ((aHighSurrogate - 0xD7F7) << 10) + aLowSurrogate; |         | 
|     65 	} |         | 
|     66  |         | 
|     67 // Creates a one or two collation keys sequence corresponding to the input character. |     29 // Creates a one or two collation keys sequence corresponding to the input character. | 
|     68 // Returns the number of keys output. |     30 // Returns the number of keys output. | 
|     69 static TInt CreateDefaultCollationKeySequence(TInt aChar, TCollationKey* aBuffer) |     31 static TInt CreateDefaultCollationKeySequence(TInt aChar, TCollationKey* aBuffer) | 
|     70 	{ |     32 	{ | 
|     71 	if (aChar >= 0x3400 && aChar <= 0x9FFF)	// CJK |     33 	if (aChar >= 0x3400 && aChar <= 0x9FFF)	// CJK | 
|     98 		if ((p < start) || (p > end))  |     60 		if ((p < start) || (p > end))  | 
|     99 			{ |     61 			{ | 
|    100 			break; |     62 			break; | 
|    101 			} |     63 			} | 
|    102 		TInt c = *p >> 16; |     64 		TInt c = *p >> 16; | 
|    103 		if (IsHighSurrogate( (TText16)c )) |     65 		if (TChar::IsHighSurrogate( (TText16)c )) | 
|    104 			{ |     66 			{ | 
|    105 			if ((p < end) && (IsLowSurrogate( (TText16)((*(p+1))>>16) ))) |     67 			if ((p < end) && (TChar::IsLowSurrogate( (TText16)((*(p+1))>>16) ))) | 
|    106 				{ |     68 				{ | 
|    107 				currentCharLength = 2; |     69 				currentCharLength = 2; | 
|    108 				c = JoinSurrogate( (TText16)(*p>>16), (TText16)((*(p+1))>>16) ); |     70 				c = TChar::JoinSurrogate( (TText16)(*p>>16), (TText16)((*(p+1))>>16) ); | 
|    109 				} |     71 				} | 
|    110 			} |     72 			} | 
|    111 		else if (IsLowSurrogate( (TText16)c )) |     73 		else if (TChar::IsLowSurrogate( (TText16)c )) | 
|    112 			{ |     74 			{ | 
|    113 			if ((p > start) && (IsHighSurrogate( (TText16)((*(p-1))>>16) ))) |     75 			if ((p > start) && (TChar::IsHighSurrogate( (TText16)((*(p-1))>>16) ))) | 
|    114 				{ |     76 				{ | 
|    115 				p--; |     77 				p--; | 
|    116 				pivot = pivot - 1; |     78 				pivot = pivot - 1; | 
|    117 				currentCharLength = 2; |     79 				currentCharLength = 2; | 
|    118 				c = JoinSurrogate( (TText16)(*p>>16), (TText16)((*(p+1))>>16) ); |     80 				c = TChar::JoinSurrogate( (TText16)(*p>>16), (TText16)((*(p+1))>>16) ); | 
|    119 				} |     81 				} | 
|    120 			} |     82 			} | 
|    121 		else |     83 		else | 
|    122 			{ |     84 			{ | 
|    123 			currentCharLength = 1; |     85 			currentCharLength = 1; | 
|    656 			{ |    618 			{ | 
|    657 			text[textLen++] = static_cast <TText> (cur_char); |    619 			text[textLen++] = static_cast <TText> (cur_char); | 
|    658 			} |    620 			} | 
|    659 		else  |    621 		else  | 
|    660 			{ |    622 			{ | 
|    661 			text[textLen++] = GetHighSurrogate(cur_char); |    623 			text[textLen++] = TChar::GetHighSurrogate(cur_char); | 
|    662 			text[textLen++] = GetLowSurrogate(cur_char); |    624 			text[textLen++] = TChar::GetLowSurrogate(cur_char); | 
|    663 			} |    625 			} | 
|    664 		TBool possible_prefix = ETrue; |    626 		TBool possible_prefix = ETrue; | 
|    665 		for(TInt i = 1; (i < KKeyedStringBufferSize) && possible_prefix; i++) |    627 		for(TInt i = 1; (i < KKeyedStringBufferSize) && possible_prefix; i++) | 
|    666 			{ |    628 			{ | 
|    667 			++moved; |    629 			++moved; | 
|    674 				{ |    636 				{ | 
|    675 				text[textLen++] = static_cast <TText> (c); |    637 				text[textLen++] = static_cast <TText> (c); | 
|    676 				} |    638 				} | 
|    677 			else |    639 			else | 
|    678 				{ |    640 				{ | 
|    679 				text[textLen++] = GetHighSurrogate(c); |    641 				text[textLen++] = TChar::GetHighSurrogate(c); | 
|    680 				text[textLen++] = GetLowSurrogate(c); |    642 				text[textLen++] = TChar::GetLowSurrogate(c); | 
|    681 				} |    643 				} | 
|    682 			TInt cur_index = -1; |    644 			TInt cur_index = -1; | 
|    683             ::GetStringKey(aTable, text, textLen, cur_index, possible_prefix); |    645             ::GetStringKey(aTable, text, textLen, cur_index, possible_prefix); | 
|    684 			if(cur_index != -1) |    646 			if(cur_index != -1) | 
|    685 				{ |    647 				{ |