Beispiel #1
0
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue)
	{
	TPtr8 ptr8((TUint8*)aValue.Ptr(), 0, aValue.MaxSize());
	TInt ret=Get(aKey,ptr8);
	if (ret==KErrNone)
		aValue.SetLength(ptr8.Length()/2);
	return ret;
	}
// -----------------------------------------------------------------------------
// 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;
    }
Beispiel #3
0
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
	KErrNone if successful,
	KErrNotFound if the setting does not exist,
	KErrArgument if the setting exists but is not a descriptor,
	KErrOverflow if the descriptor is too small to receive the value in the repository,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes16& aValue, TInt& aActualLength)
	{
	TInt actualLength8;
	TPtr8 ptr8((TUint8*)aValue.Ptr(), 0, aValue.MaxSize());
	TInt ret=Get(aKey,ptr8,actualLength8);
	aValue.SetLength(ptr8.Length()/2);			
	aActualLength=actualLength8/2;		
	return ret;
	}
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('?');
  }
}
Beispiel #5
0
TInt TEnvVar::Externalize(TDes16& aBuffer)
	{
	if (iName==0) 
		return 0;
	aBuffer.Append(*iName);
	aBuffer.Append(TChar(0));
	aBuffer.Append(*iValue);
	aBuffer.Append(TChar(0));
	return 1;
	}
Beispiel #6
0
EXPORT_C TInt CLANLinkCommon::ReadDes(const TDesC& aField, TDes16& aValue)
{
	// Emulate reading of following parameters only:
	// LAN_BEARER\LAN_BEARER_LDD_FILENAME
	// LAN_BEARER\LAN_BEARER_LDD_NAME
	// LAN_BEARER\LAN_BEARER_PDD_FILENAME
	// LAN_BEARER\LAN_BEARER_PDD_NAME

	_LIT(KLanBearer, "LANBearer\\");
	const TInt KLanBearerTokenSize = 10;

	TPtrC field(aField.Left(KLanBearerTokenSize));	// "LANBearer"

	if (field.Compare(KLanBearer()) == 0)
		{
		_LIT(KLanBearerLddFilename, "LDDFilename");
		_LIT(KLanBearerLddName, "LDDName");
		_LIT(KLanBearerPddFilename, "PDDFilename");
		_LIT(KLanBearerPddName, "PDDName");

		field.Set(aField.Mid(KLanBearerTokenSize));	// skip "LANBearer\\"
		if (field.CompareF(KLanBearerLddFilename) == 0)
			{
			aValue.Copy(LinkProvision().LddFilename());
			}
		else
		if (field.CompareF(KLanBearerLddName) == 0)
			{
			aValue.Copy(LinkProvision().LddName());
			}
		else
		if (field.CompareF(KLanBearerPddFilename) == 0)
			{
			aValue.Copy(LinkProvision().PddFilename());
			}
		else
		if (field.CompareF(KLanBearerPddName) == 0)
			{
			aValue.Copy(LinkProvision().PddName());
			}
		else
			{
			return KErrNotSupported;
			}
		return KErrNone;
		}
	else
		{
		return KErrNotSupported;
		}
}
TInt CDummyNifAgentRef::DoReadDes(const TDesC& aField, TDes16& aValue,const RMessagePtr2* /*aMessage*/)
{
	TInt result = KErrNotFound;
	if (ipIniFileReader !=0)
	{
		TPtrC value;
		if (ipIniFileReader->FindVar(iData.KCommDbSectionName,aField,value))
		{
			aValue.Copy(value);
			result=KErrNone;
		}
	}
	//use hardcoded only if the ini file read or search failed
	if (KErrNotFound==result)
	{
		result=KErrNone;
		//
		if (TPtrC(KCDTypeNameRecordName)==aField)
			aValue=iData.KPppCommdbName;
		else if (iData.KModemPortString==aField)
			aValue=iData.KPppPortString;
		else if (iData.KModemCsyString==aField)
			aValue=iData.KPppCsyString;
		else
			result=KErrNotFound;
	}
	//
	LOG_ERR_PRINTF4(_L("--------------- Config param used: %S = %S (err %d)"),&aField,&aValue,result);
	//
	return result;
}
// -----------------------------------------------------------------------------
// UnicodeTextUtil::ConvertASCIIInPlace
// Converts all ASCII *in-place* from either Half to Full-width or vice versa,
// depending on the direction specified by aDirection.
// Returns: The total number of characters converted.
// -----------------------------------------------------------------------------
//
TInt UnicodeTextUtil::ConvertASCIIInPlace( TConvDirection aDirection,
                                           TDes16& aUnicodeText )
    {
    TInt totalConverted( 0 );
    TText lowerBound( ( aDirection == EHalfToFullWidth ) ?
                        KHalfWidthASCIILowerBound :
                        KFullWidthASCIILowerBound );
    TText upperBound( ( aDirection == EHalfToFullWidth ) ?
                        KHalfWidthASCIIUpperBound :
                        KFullWidthASCIIUpperBound );
    TInt offset( ( aDirection == EHalfToFullWidth ) ?
                   KHalfToFullWidthASCIIOffset :
                   -KHalfToFullWidthASCIIOffset );
    for( TInt i( 0 ); i < aUnicodeText.Length(); ++i )
        {
        const TText uniChar( aUnicodeText[i] );
        if( uniChar >= lowerBound && uniChar <= upperBound )
            {
            TText convertedChar( static_cast<TText>( uniChar + offset ) );
            aUnicodeText[i] = convertedChar;
            totalConverted++;
            }
        }
    return totalConverted;
    }
/**
Reads data from the stream buffer into the specified descriptor.
On return, contains the data read from the stream buffer

@param aDes The target descriptor for the data read from the stream buffer
@param aLength The maximum number of bytes to be read
@return KErrNone If all bytes read successfully.
@return	KErrCorrupt If reading fails.
@return KErrEof If end of file is reached.
@return ... Any one of the system-wide error codes for other errors.
*/
EXPORT_C TInt RZipFileMemberReaderStream::Read(TDes16& aDes, TInt aLength)
{
	TUint32 numBytesRead = 0;
	TInt err = Read(CONST_CAST(TByte*,(const TByte*)aDes.Ptr()), 2*aLength, &numBytesRead);
	if (err != KErrNone)
	{
		aDes.SetLength( (err==KErrEof) ? numBytesRead>>2 : 0 );
		return err;
	}
void CMemSpyMemStreamReader::ReadL( TDes16& aDes )
    {
    // The kernel driver only ever writes narrow descriptors.
    // However, we can expand them to be UCS2
    const TInt length = ReadInt32L();

    // Need to check the remaining text is actually present...
    IsAvailableL( length );

    // Set final length in descriptor
    aDes.SetLength( length );

    // Read each char
    TUint16* dest = const_cast< TUint16* >( aDes.Ptr() );
    for( TInt i=0; i<length; i++ )
        {
        *dest++ = *iCurrent++;
        }
    }
 /**
   * Converts a descriptor of type TBuf16 to character stream
   *
   * @param aSrc is the descriptor to be converted , aDes is the 
   * reference to the character sream where the result of conversion 
   * is stored , n_size specifies the conversion size of the string 
   * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   * -2 is EInvalidSize , -4 is EInvalidPointer, -8 is EInvalidWCSSequence)
   */
EXPORT_C int Tbuf16ToChar(TDes16& aSrc, char* aDes, int& n_size)
{	
    unsigned int ilen = aSrc.Length();
    int retval = ESuccess;
    wchar_t *temp16String = NULL;
    int minusone = -1;
    
    if (0 == ilen)
    {
    	return EDescriptorNoData;
    }
    else if(!aDes)
    {
    	return EInvalidPointer;
    }
    
    else if(n_size < ilen*2+1)
    {
    	n_size = ilen*2;
    	return EInvalidSize;
    }
        		
	temp16String = new wchar_t [ilen+1];
	if (!temp16String)
	{
		return EInsufficientSystemMemory;
	}
	
	wmemcpy(temp16String, (const wchar_t *)aSrc.Ptr(), ilen);
	temp16String[ilen] = L'\0'; 	
	
	if(minusone != wcstombs(aDes, (const wchar_t*)temp16String, ilen*2))
	{
	    aDes[ilen*2] = '\0'; 
	}
	else 
	{
		retval = EInvalidWCSSequence;
	}
	
	delete []temp16String;	
	return retval;
}
EXPORT_C int WcharToTbuf16(const wchar_t* aSrc, TDes16& aDes)
{
    unsigned int ilen = 0;
	if ( !aSrc )
	{
		return EInvalidPointer;
	}
	else
	{
		ilen = wcslen(aSrc);
		if(ilen > aDes.MaxLength())
		{
			return EInsufficientMemory; 
		}	
	}
	
	aDes.Copy((const TUint16*)aSrc, ilen);
	return ESuccess;
}
Beispiel #13
0
void CT_KOI8R::Merge_Big(TDesC8& aSource, TDes16& aTarget)
	{
	TInt length = aSource.Length();
	TInt i = 0;
	for(i=0;i<length-1;i++)
		{
		TInt64 temp = *(aSource.Ptr()+(i))*16*16 + *(aSource.Ptr()+i+1);
		aTarget.Append(temp);
		i++;
		}	
	}
Beispiel #14
0
/** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3)

	@param aBuffer The filename will be returned here
	@param aLong   Defines the longitude of the file name 
	@param aPos	   Defines the number that will be attached to the filename
*/
void FileNameGen(TDes16& aBuffer, TInt aLong, TInt aPos) 
{
	TInt padding;
	TInt i=0;
	TBuf16<10> tempbuf;
	
	_LIT(KNumber,"%d");
	tempbuf.Format(KNumber,aPos);
	padding=aLong-tempbuf.Size()/2;
	aBuffer=_L("");
	while(i<padding)
	{
		aBuffer.Append('F');
		i++;
	}
	aBuffer.Append(tempbuf);
	
	_LIT(KExtension1, ".TXT");
	aBuffer.Append(KExtension1);
}
//translate from unicode big endian TDesC8 to TDes16
void CT_TURKISHLOCKING::Unicode_Big(TDesC8& aSource, TDes16& aTarget)
	{
	TInt length = aSource.Length();
	TInt i = 0;
	for(i=0;i<length-1;i++)
		{
		TInt32 temp = *(aSource.Ptr()+(i))*16*16 + *(aSource.Ptr()+i+1);
		aTarget.Append(temp);
		i++;
		}	
	}
EXPORT_C int WstringToTbuf16(wstring& aSrc, TDes16& aDes)
{
    int retval = ESuccess;
    const wchar_t* wcharString = aSrc.c_str();
    
    if (L'\0' == wcharString[0])
    {
    	return EStringNoData;
    }
    
    int len= wcslen(wcharString);
    if ((wcslen(wcharString)) > aDes.MaxLength())
    if (len > aDes.MaxLength())
    {
    	return EInsufficientMemory;
    }
    
	aDes.Copy((const TUint16*)wcharString);
	
    return retval;	
}
Beispiel #17
0
TInt TEnvVar::Externalize(const wchar_t* aPair, TDes16& aBuffer)
//
// static function to externalize a "name=value" definition
//
	{
	const wchar_t* cp=aPair;
	for (cp=aPair; *cp; ++cp)
		{
		if (*cp==L'=')
			break;
		}
	if (*cp!=L'=')
		return 0;	// malformed

	TPtrC16 name((TText16*)aPair,cp-aPair);
	TPtrC16 value((TText16*)(cp+1));
	aBuffer.Append(name);
	aBuffer.Append(TChar(0));
	aBuffer.Append(value);
	aBuffer.Append(TChar(0));
	return 1;
	}
Beispiel #18
0
// ---------------------------------------------------------------------------
// RFotaEngineSession::GetUpdatePackageIds
// Gets ids of the update packages present in the system.
// ---------------------------------------------------------------------------
EXPORT_C TInt RFotaEngineSession::GetUpdatePackageIds(TDes16& aPackageIdList)
    {
    TInt err;
    FLOG(_L("RFotaEngineSession::GetUpdatePackageIds >>"));
    TBuf<10> b; b.Copy(_L("dkkd"));
    TPkgIdList                  pkgids;
    TPckg<TPkgIdList>           pkgids_pkg(pkgids);
    TIpcArgs                    args ( &pkgids_pkg);
    err = SendReceive ( EGetUpdatePackageIds, args);
    aPackageIdList.Copy(pkgids);
    FLOG(_L("RFotaEngineSession::GetUpdatePackageIds <<"));
    return err;
    }
 /**
   * Converts a descriptor of type RBuf16 to Wstring
   *
   * @param aSrc is the descriptor to be converted , aDes is the 
   * reference to the Wstring array where the result of conversion 
   * is stored  
   * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   *  -2 is EInvalidSize , -4 is EInvalidPointer , -5 is EDescriptorNoData)
   */
EXPORT_C int Rbuf16ToWstring(TDes16& aSrc, wstring& aDes)
{
    unsigned int ilen = aSrc.Length();
    if (0 == ilen)
    {
    	return EDescriptorNoData;
    }
    
    wchar_t* buf = new wchar_t[ilen+1];
    if(!buf)
    {
    	return EInsufficientSystemMemory;
    }
    
   	wmemcpy (buf,(wchar_t *)aSrc.Ptr(), ilen);
    buf[ilen]=L'\0';
    
    aDes.assign(buf);
	delete[] buf;
	
	return ESuccess;
}
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);	
    }
EXPORT_C int Tbuf16ToWstring(TDes16& aSrc, wstring& aDes)
{	
   
    unsigned int ilen = aSrc.Length();
    if (0 == ilen)
	{
		return EDescriptorNoData;
	}
	
	wchar_t* wcharString = new wchar_t[ilen+1];
	if (!wcharString)
	{
		return EInsufficientSystemMemory;
	}
	
	wmemcpy((wchar_t*)wcharString, (const wchar_t*)aSrc.Ptr(), ilen);
	wcharString[ilen] = L'\0';
	
	aDes.assign(wcharString);
	
	delete []wcharString;
	return ESuccess;
}
Beispiel #22
0
void CEnvironment::ConstructL(TUint aCount, TDes16& aBuffer)
//
// Set up the environment from a descriptor. If this leaves then
// the CEnvironment destructor will be able to clean up properly.
//
	{
	// always allocate at least one slot - makes life easier elsewhere
	TInt bytes = (aCount+1)*sizeof(TEnvVar);
	iVars=(TEnvVar*) User::AllocL(bytes);
	Mem::FillZ(iVars,bytes);
	iCount=aCount+1;

	const TText16* data=aBuffer.Ptr();
	for (TUint i=0; i<aCount; ++i)
		iVars[i].ConstructL(data);
	}
static void Hellenize(TDes16& text)
{
    static const TUint16* roman = (TUint16*)(L"ABGDEZJQIKLMNXOPRVSTUFHCW");

    for (int i = 0; i < text.Length(); i++)
        for (int j = 0; j < 25; j++)
            if (roman[j] == text[i])
            {
                text[i] = (TUint16)(0x391 + j);
                break;
            }
            else if (roman[j] + 32 == text[i])
            {
                text[i] = (TUint16)(0x3B1 + j);
                break;
            }
}
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('?');
  }
}
Beispiel #25
0
// -----------------------------------------------------------------------------
// UnicodeTextUtil::ConvertSpecialCharactersInPlace
// Converts all special characters in the aUnicodeText descriptor in-place
// that have both Full and Half-width variants.
// Conversion occurs in the direction specified by aDirection.
// Returns: The total number of characters converted.
// -----------------------------------------------------------------------------
//
TInt UnicodeTextUtil::ConvertSpecialCharactersInPlace
                             ( TConvDirection aDirection, TDes16& aUnicodeText )
    {
    TInt totalConverted( 0 );
    const TInt directionIndex( ( aDirection == EHalfToFullWidth ) ?
                                 KHalfWidthIndex : KFullWidthIndex );
    for( TInt i( 0 ); i < aUnicodeText.Length(); ++i )
        {
        const TText uniChar( aUnicodeText[i] );
        for( TInt j( 0 ); j < KHalfWidthSpecialCharRange; ++j )
            {
            if( uniChar == KHalfToFullWidthSpecialCharTable[j][directionIndex] )
                {
                aUnicodeText[i] =
                    KHalfToFullWidthSpecialCharTable[j][!directionIndex];
                totalConverted++;
                break;
                }
            }
        }
    return totalConverted;
    }
/*
-------------------------------------------------------------------------------

    Class: TDesLoggerOverflowHandler

    Method: Overflow

    Description: Simple overflow handling(16 bit)

    Parameters: TDes16 &aDes: in: Reference to over flow data

    Return Values: None

    Errors/Exceptions: None

    Status: Approved

-------------------------------------------------------------------------------
*/
void TDesLoggerOverflowHandler::Overflow( TDes16& aDes )
    {
    __TRACE( KError, ( _L( "STIFLOGGER: Over flow" ) ) );

    // If overflow
    TInt len( 0 );
    len = aDes.Length();

    // const TInt to TInt avoiding warnings
    TInt maxLogData = KMaxLogData;
    TInt maxTestFileName = KMaxFileName;

    // Overflow: Log() without aStyle or Log() with aStyle
    if ( ( iOverFlowSource == 1 || iOverFlowSource == 2 )
            &&  maxLogData > 60 )
        {
        // Log overflow info if info is in allowed limits
        aDes[len-2] = 13;   // 13 or '\' in Symbian OS
        aDes[len-1] = 10;   // 10 or 'n' in Symbian OS
        // ~60
        iLogger->Send( 0, _L("Log() OVERFLOW: Check aLogInfo and KMaxLogData !!!") );
        }
    // Overflow: WriteDelimiter()
    if ( iOverFlowSource == 3 &&  maxLogData > 70 )
        {
        // Log overflow info if info is in allowed limits, ~70
        iLogger->Send( 0, _L( "WriteDelimiter() OVERFLOW: Check delimiter and KMaxLogData !!!" ) );
        }
    // Overflow: StartHtmlPage()
    if ( iOverFlowSource == 4 &&  maxTestFileName > 70 )
        {
        // Log overflow info if info is in allowed limits, ~70
        iLogger->Send( 0, _L( "aTestFile OVERFLOW: Check aTestFile and KMaxFileName !!!" ) );
        }

    }
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;
  }
}
Beispiel #28
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;
    }
Beispiel #29
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;
    }
void CBatmonContainer::Hour(TDes16& aValue,TUint16 aAddress) const
{
  Value(KPhoneEnergyUnit,aAddress,aValue);
  aValue.Append(_L(" h"));
}