equal
deleted
inserted
replaced
107 { |
107 { |
108 #if defined( Q_OS_SYMBIAN ) |
108 #if defined( Q_OS_SYMBIAN ) |
109 TPtrC s1Ptr( strFrom.utf16() ); |
109 TPtrC s1Ptr( strFrom.utf16() ); |
110 TPtrC s2Ptr( strToMatch.utf16() ); |
110 TPtrC s2Ptr( strToMatch.utf16() ); |
111 |
111 |
112 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
112 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
113 maxLevel = 0; |
113 maxLevel = 0; |
114 } |
114 } |
115 if ( (flags < 0) || (flags > 127) ) { |
115 if ( (flags < 0) || (flags > 127) ) { |
116 flags = Default; |
116 flags = Default; |
117 } |
117 } |
118 |
118 |
119 TCollationMethod m = *Mem::GetDefaultMatchingTable(); |
119 TCollationMethod m = *Mem::GetDefaultMatchingTable(); |
152 Level 2 - Character identity, accents and case; |
152 Level 2 - Character identity, accents and case; |
153 Level 3 - Character identity, accents, case and Unicode value; |
153 Level 3 - Character identity, accents, case and Unicode value; |
154 \param flags The flags that will be used. Default value is Default. |
154 \param flags The flags that will be used. Default value is Default. |
155 |
155 |
156 \return Positive if source string is greater, negative if it is less and |
156 \return Positive if source string is greater, negative if it is less and |
157 zero if the content of both strings match. |
157 zero if the content of both strings match. |
158 |
158 |
159 Example: |
159 Example: |
160 \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,1} |
160 \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,1} |
161 */ |
161 */ |
162 int HbStringUtil::compareC( const QString &string1, const QString &string2, |
162 int HbStringUtil::compareC( const QString &string1, const QString &string2, |
164 { |
164 { |
165 #if defined( Q_OS_SYMBIAN ) |
165 #if defined( Q_OS_SYMBIAN ) |
166 TPtrC s1Ptr(string1.utf16()); |
166 TPtrC s1Ptr(string1.utf16()); |
167 TPtrC s2Ptr(string2.utf16()); |
167 TPtrC s2Ptr(string2.utf16()); |
168 |
168 |
169 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
169 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
170 maxLevel = 3; |
170 maxLevel = 3; |
171 } |
171 } |
172 if ( (flags < 0) || (flags > 127) ) { |
172 if ( (flags < 0) || (flags > 127) ) { |
173 flags = Default; |
173 flags = Default; |
174 } |
174 } |
175 |
175 |
176 TCollationMethod m = *Mem::CollationMethodByIndex( 0 ); |
176 TCollationMethod m = *Mem::CollationMethodByIndex( 0 ); |
211 { |
211 { |
212 #if defined( Q_OS_SYMBIAN ) |
212 #if defined( Q_OS_SYMBIAN ) |
213 TPtrC s1Ptr( strFrom.utf16() ); |
213 TPtrC s1Ptr( strFrom.utf16() ); |
214 TPtrC s2Ptr( strToFind.utf16() ); |
214 TPtrC s2Ptr( strToFind.utf16() ); |
215 |
215 |
216 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
216 if ( (maxLevel < 0) || (maxLevel > 3) ) { |
217 maxLevel = 0; |
217 maxLevel = 0; |
218 } |
218 } |
219 return s1Ptr.FindC( s2Ptr.Ptr(), |
219 return s1Ptr.FindC( s2Ptr.Ptr(), |
220 s2Ptr.Length(), |
220 s2Ptr.Length(), |
221 maxLevel ); |
221 maxLevel ); |
222 #else |
222 #else |
223 Q_UNUSED(maxLevel); |
223 Q_UNUSED(maxLevel); |
341 |
341 |
342 \param str digits to be converted. |
342 \param str digits to be converted. |
343 */ |
343 */ |
344 QString HbStringUtil::convertDigits( const QString str ) |
344 QString HbStringUtil::convertDigits( const QString str ) |
345 { |
345 { |
346 HbExtendedLocale locale = HbExtendedLocale::system(); |
346 HbExtendedLocale locale = HbExtendedLocale::system(); |
347 DigitType digitType = WesternDigit; |
347 DigitType digitType = WesternDigit; |
348 if (locale.language() == HbExtendedLocale::Arabic) { |
348 if (locale.language() == HbExtendedLocale::Arabic) { |
349 digitType = ArabicIndicDigit; |
349 digitType = ArabicIndicDigit; |
350 } else if (locale.language() == HbExtendedLocale::Persian || locale.language() == HbExtendedLocale::Urdu) { |
350 } else if (locale.language() == HbExtendedLocale::Persian || locale.language() == HbExtendedLocale::Urdu) { |
351 digitType = EasternArabicIndicDigit; |
351 digitType = EasternArabicIndicDigit; |
352 } |
352 } |
353 QString converted = HbStringUtil::convertDigitsTo(str, digitType); |
353 QString converted = HbStringUtil::convertDigitsTo(str, digitType); |
354 return converted; |
354 return converted; |
355 } |
355 } |
356 |
356 |
357 /*! |
357 /*! |
358 Converts the digit from Latin to native or native to latin or native to native |
358 Converts the digit from Latin to native or native to latin or native to native |
359 |
359 |
380 case ThaiDigit: |
380 case ThaiDigit: |
381 convertedDigit += digitType + digit - digitBase; |
381 convertedDigit += digitType + digit - digitBase; |
382 convDigit[i] = QChar(convertedDigit); |
382 convDigit[i] = QChar(convertedDigit); |
383 break; |
383 break; |
384 default: |
384 default: |
385 convDigit[i] = QChar(digit); |
385 convDigit[i] = QChar(digit); |
386 break; |
386 break; |
387 }; |
387 }; |
388 } |
388 } |
389 return convDigit; |
389 return convDigit; |
390 } |
390 } |
399 Example: |
399 Example: |
400 \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,7} |
400 \snippet{unittest_hbstringutil/unittest_hbstringutil.cpp,7} |
401 */ |
401 */ |
402 void HbStringUtil::sort( QStringList &strList ) |
402 void HbStringUtil::sort( QStringList &strList ) |
403 { |
403 { |
404 if ( strList.size() > 1 ) { |
404 if ( strList.size() > 1 ) { |
405 qSort(strList.begin(), strList.end(), hbStringUtil_SortHelper); |
405 qSort(strList.begin(), strList.end(), hbStringUtil_SortHelper); |
406 } |
406 } |
407 } |
407 } |
408 |
408 |
409 bool hbStringUtil_SortHelper( const QString &s1, const QString &s2 ) |
409 bool hbStringUtil_SortHelper( const QString &s1, const QString &s2 ) |
410 { |
410 { |
411 if ( HbStringUtil::compareC(s1, s2) < 0 ) { |
411 if ( HbStringUtil::compareC(s1, s2) < 0 ) { |
412 // s1 is before s2 |
412 // s1 is before s2 |
413 return true; |
413 return true; |
414 } else { |
414 } else { |
415 // s1 is after s2 (or they are equal) |
415 // s1 is after s2 (or they are equal) |
416 return false; |
416 return false; |
417 } |
417 } |
418 } |
418 } |