Пример #1
0
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullHiragnaToFullKatakana
// Converts Full-width Hiragana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the
// resulting text into aUnicodeTarget.
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullHiragnaToFullKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    const TInt maxLength( aUnicodeTarget.MaxLength() );
    if( length > maxLength )
        {
        return KErrTooBig;
        }

    const TUint comp = KFullWidthKatakanaSmallA - KFullWidthHiraganaSmallA;

    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        TText uniChar2(0);
        if (i + 1 < length)
            {
            uniChar2 = aUnicodeSource[i+1];
            }
        // First check if this is this Full Width Katakana
        if (KFullWidthHiraganaSmallA <= uniChar && uniChar <= KFullWidthHiraganaVU)
            {
            if (uniChar == KFullWidthHiraganaU
             && uniChar2 == KFullWidthHiraganaVoicedSound)
                {
                aUnicodeTarget.Append(KFullWidthKatakanaSmallVU);
                totalConverted++;
                i++;
                }
            else
                {
                TUint katakana = uniChar + comp;
                if (IsKatakana(katakana))
                    {
                    aUnicodeTarget.Append(katakana);
                    totalConverted++;
                    }
                }
            }
        else
            {
            aUnicodeTarget.Append(uniChar);
            totalConverted++;
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another loop over
    // the text
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }
Пример #2
0
void CBatmonContainer::Value(TUint8 aUnit,TUint16 aAddress,TDes16& aValue) const
{
  TRAPD(err,HWNetmon::ValueL(aUnit,aAddress,aValue,HWNetmon::EExt|HWNetmon::ESigned));
  if(err!=KErrNone)
  {
    aValue.Zero();
    aValue.Append('?');
  }
}
Пример #3
0
void Big5::ConvertToUnicodeL(TDes16& aUnicode, const TDesC8& aForeign, TFatUtilityFunctions::TOverflowAction aOverflowAction)
    {
    TInt err = KErrNone;	
    aUnicode.Zero();
    TRAP(err, UnicodeConv::ConvertToUnicodeL(aUnicode, aForeign));		
    
    // Ignore overflow errors if you're allowed to truncate the string
    if (aOverflowAction == TFatUtilityFunctions::EOverflowActionTruncate && err == KErrOverflow)
        {
        err = KErrNone;
        }

    User::LeaveIfError(err);	
    }
Пример #4
0
void CBatmonContainer::Temperature(TDes16& aValue,TUint16 aAddress) const
{
  TRAPD(err,HWNetmon::ValueL(KPhoneEnergyUnit,aAddress,aValue,HWNetmon::EExt|HWNetmon::ERaw));
  if(err==KErrNone&&aValue.Length()>2)
  {
    TInt value=aValue[1]*256+aValue[2]-273;
    aValue.Num(value);
    aValue.Append(0xb0);
    aValue.Append('C');
  }
  else
  {
    aValue.Zero();
    aValue.Append('?');
  }
}
Пример #5
0
void CBatmonContainer::Battery(TDes16& aValue,TUint16 aAddress) const
{
  TInt value=0;
  TRAPD(err,HWNetmon::ValueL(KPhoneEnergyUnit,aAddress,aValue,HWNetmon::EExt|HWNetmon::ERaw));
  if(err==KErrNone&&aValue.Length()>0) value=aValue[0];
  aValue.Zero();
  switch(value)
  {
    case 11:
      aValue.Append(_L("BL-4C"));
      break;
    case 12:
      aValue.Append(_L("BL-5C"));
      break;
    case 17:
      aValue.Append(_L("BL-6C"));
      break;
    default:
      aValue.Append('?');
      break;
  }
}
Пример #6
0
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertFullToHalfWidthKatakana
// Converts Full-width Katakana and Special Character text found in
// aUnicodeSource to their Half-width counterparts and places the resulting text
// into aUnicodeTarget. There will be a 2-for-1 conversion for each Full-width
// Voiced and Semi-voiced Katakana character.
// (detailed information about the parameters and return values can be found in
// the header file)
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertFullToHalfWidthKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    const TInt maxLength( aUnicodeTarget.MaxLength() );
    if( length > maxLength )
        {
        return KErrTooBig;
        }
    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        // First check if this is this Full Width Katakana
        if( ( uniChar >= KFullWidthKatakanaLowerBound &&
              uniChar <= KFullWidthKatakanaUpperBound ) ||
            ( uniChar == KFullWidthKatakanaVoicedSoundMark ||
              uniChar == KFullWidthKatakanaSemiVoicedSoundMark ) )
            {
            // Then check if it is (Semi-)Voiced and convert it properly
            const TBool isVoiced(
                UnicodeTextUtil::IsFullWidthVoicedKatakana( uniChar )
            );
            const TBool isSemiVoiced(
                UnicodeTextUtil::IsFullWidthVoicedKatakana( uniChar, ETrue )
            );
            if( isVoiced || isSemiVoiced )
                {
                if( aUnicodeTarget.Length() + 2 > maxLength )
                    {
                    // This descriptor can't hold the new data
                    aUnicodeTarget.Zero();
                    return KErrTooBig;
                    }
                UnicodeTextUtil::ConvertVoicedKatakanaCharAndAppendToTarget(
                    EFullToHalfWidth,
                    uniChar,
                    aUnicodeTarget,
                    isSemiVoiced
                );
                totalConverted++;
                }
            else
                {
                if( aUnicodeTarget.Length() + 1 > maxLength )
                    {
                    // This descriptor can't hold the new data
                    aUnicodeTarget.Zero();
                    return KErrTooBig;
                    }
                aUnicodeTarget.Append(
                    UnicodeTextUtil::ConvertKatakanaChar(
                        EFullToHalfWidth,
                        uniChar
                    )
                );
                totalConverted++;
                }
            }
        // This is not Full Width Katakana, so copy directly...
        else
            {
            if( aUnicodeTarget.Length() + 1 > maxLength )
                {
                // This descriptor can't hold the new data
                aUnicodeTarget.Zero();
                return KErrTooBig;
                }
            const TChar uniCharacter( uniChar );
            aUnicodeTarget.Append( uniCharacter );
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another loop over
    // the text
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EFullToHalfWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }
Пример #7
0
// -----------------------------------------------------------------------------
// JPLangUtil::ConvertHalfToFullWidthKatakana
// Converts Half-width Katakana and Special Character text found in
// aUnicodeSource to their Full-width counterparts and places the resulting text
// into aUnicodeTarget.
// (detailed information about the parameters and return values can be found in
// the header file)
// -----------------------------------------------------------------------------
//
EXPORT_C TInt JPLangUtil::ConvertHalfToFullWidthKatakana
                       ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget )
    {
    TInt totalConverted( 0 );
    const TInt length( aUnicodeSource.Length() );
    if( length > aUnicodeTarget.MaxLength() )
        {
        return KErrTooBig;
        }
    aUnicodeTarget.Zero();
    for( TInt i( 0 ); i < length; ++i )
        {
        const TText uniChar( aUnicodeSource[i] );
        // Check if the next character is a Half Width Katakana (Semi-)Voiced
        // Sound Mark and if the current character + the voiced sound mark have
        // a Full Width counterpart
        if( i + 1 < length )
            {
            const TBool isVoiced(
            ( UnicodeTextUtil::IsFullWidthVoicedConvertableHalfWidthBaseKatakana
                  ( uniChar ) &&
              ( aUnicodeSource[i + 1] == KHalfWidthKatakanaVoicedSoundMark )
            ) );

            const TBool isSemiVoiced(
            ( UnicodeTextUtil::IsFullWidthVoicedConvertableHalfWidthBaseKatakana
                  ( uniChar, ETrue ) &&
              ( aUnicodeSource[i + 1] == KHalfWidthKatakanaSemiVoicedSoundMark )
            ) );

            if( isVoiced || isSemiVoiced )
                {
                UnicodeTextUtil::ConvertVoicedKatakanaCharAndAppendToTarget(
                    EHalfToFullWidth,
                    uniChar,
                    aUnicodeTarget,
                    isSemiVoiced
                );
                i++; // Skip the (semi-)voice marker
                totalConverted++;
                continue;
                }
            }
        // If not, then just convert directly if in range
        if( uniChar >= KHalfWidthKatakanaLowerBound &&
            uniChar <= KHalfWidthKatakanaUpperBound )
            {
            aUnicodeTarget.Append(
                UnicodeTextUtil::ConvertKatakanaChar( EHalfToFullWidth,
                                                      uniChar )
            );
            totalConverted++;
            }
        // Else this is not Half Width Katakana, so copy directly...
        else
            {
            const TChar uniCharacter( uniChar );
            aUnicodeTarget.Append( uniCharacter );
            }
        }

    // Now handle special characters
    // This logic may be moved into this function to avoid another
    // loop over the text.
    totalConverted +=
        UnicodeTextUtil::ConvertSpecialCharactersInPlace( EHalfToFullWidth,
                                                          aUnicodeTarget );

    return totalConverted;
    }