/** This routine is used to convert Arabic-Indic, Eastern Arabic-Indic or Devanagari digits to European digits. @param aDes Parameter to change */ void CResourceLoader::LanguageSpecificNumberConverter::ConvertToWesternNumbers( TDes &aDes ) { const TChar toArea = 0x030; const TInt KLastDevanagariDigit = 0x96F; const TInt KFirstDevanagariDigit = 0x966; const TInt length = aDes.Length(); for( TInt i=0; i<length; i++ ) { TChar character = aDes[i]; TChar fromArea = NumberToBase( character ); TChar::TBdCategory cat = character.GetBdCategory(); if ( cat == TChar::EArabicNumber || cat == TChar::EEuropeanNumber || ( KFirstDevanagariDigit <= character && character <= KLastDevanagariDigit ) ) { character += toArea; character -= fromArea; aDes[i] = TUint16( character ); } } }
/** This routine is used to convert between European digits and Arabic-Indic, Eastern Arabic-Indic, Devanagari or Thai digits based on existing digit type setting. @param aDes Parameter to change */ void CResourceLoader::LanguageSpecificNumberConverter::Convert( TDes &aDes ) { TLocale locale; locale.Refresh(); const TDigitType digitType = locale.DigitType(); TChar toArea = 0x030; switch( digitType ) { case EDigitTypeWestern: case EDigitTypeArabicIndic: case EDigitTypeEasternArabicIndic: case EDigitTypeDevanagari: case EDigitTypeThai: toArea = digitType; break; case EDigitTypeUnknown: case EDigitTypeAllTypes: return; } const TInt length = aDes.Length(); for( TInt i = 0; i < length; i++ ) { TChar character = aDes[i]; TChar fromArea = NumberToBase( character ); TChar::TBdCategory cat = character.GetBdCategory(); switch( cat ) { case TChar::EArabicNumber: case TChar::EEuropeanNumber: character += toArea; character -= fromArea; aDes[i] = TUint16( character ); break; default: break; } } }