Exemplo n.º 1
0
/**
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0538
@SYMTestCaseDesc        Splitting and converting from EucJpPacked to Unicode test
@SYMTestPriority        Medium
@SYMTestActions         Tests for conversion after splitting, from EucJpPacked to Unicode and back to EucJpPacked
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void CT_EUCJP_PACKED_2::TestSplittingConvertingToUnicodeFromEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfEucJpPackedBytesNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfUnicode, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalEucJpPacked)
	{
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0538 "));
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
	test(aMaximumLengthUpperLimit<=KBufferLength);
	TUint16 unicodeBuffer[KBufferLength];
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
		{
		TPtr16 generatedFirstPartOfUnicode(unicodeBuffer, i);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		test(aCharacterSetConverter.ConvertToUnicode(generatedFirstPartOfUnicode, aOriginalEucJpPacked, state)==aExpectedNumberOfEucJpPackedBytesNotConvertedAtSplit);
		test(generatedFirstPartOfUnicode==aExpectedUnicode.Left(aExpectedLengthOfFirstPartOfUnicode));
		test(state==CCnvCharacterSetConverter::KStateDefault);
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, aOriginalEucJpPacked.Right(aExpectedNumberOfEucJpPackedBytesNotConvertedAtSplit), state)==0);
		test(generatedSecondPartOfUnicode==aExpectedUnicode.Mid(aExpectedLengthOfFirstPartOfUnicode));
		test(state==CCnvCharacterSetConverter::KStateDefault);
		TBuf8<KBufferLength> generatedEucJpPacked;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedEucJpPacked, generatedFirstPartOfUnicode)==0);
		TBuf8<KBufferLength> generatedSecondPartOfEucJpPacked;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfEucJpPacked, generatedSecondPartOfUnicode)==0);
		generatedEucJpPacked.Append(generatedSecondPartOfEucJpPacked);
		test(generatedEucJpPacked==aOriginalEucJpPacked);
		}
	}
Exemplo n.º 2
0
/** Sets an existing descriptor setting to a new value or creates a new setting
with a descriptor value if it doesn't exist.
@param aKey Key of setting to be written to.
@param aValue Value to be written.
@return
	KErrNone if successful,
	KErrArgument if aValue is longer than KMaxUnicodeStringLength or
	the setting exists but is not a descriptor,
	plus other system-wide error codes.
@post
	Transactions fail on all error conditions.
	Outside transactions: on success the new value is persistent,
	on failure the repository is unmodified.
@capability Dependent Caller must satisfy the write access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Set(TUint32 aKey, const TDesC16& aValue)
	{
	if (aValue.Length()>KMaxUnicodeStringLength)
		return KErrArgument;	
	TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2);
	return Set(aKey,pVal);
	}
Exemplo n.º 3
0
// ==========================================================================
// METHOD:  Write
//
// DESIGN:  Write the given buffer.  Chunk the string if it is longer than
//          KMaxTextPerLine. 
// ==========================================================================
void CLogFileHandler::Write( const TDesC8&  aClassName,
                             const TDesC8&  aFuncName,
                             const TDesC16& aDes )
    {
    TRAP_IGNORE( AddTimestampToOutputBufferL() );
        
    TInt prefixLength = iOutputBuffer.Length();
        
    TRAP_IGNORE( AddClassAndFunctionToOutputBufferL( aClassName, aFuncName ) );
            
    TInt curPos = 0;
    
	while( curPos < aDes.Length() )
	    {
        TInt lengthToWrite = Min( KMaxTextPerLine - iOutputBuffer.Length(), aDes.Length() - curPos );
        
		TRAP_IGNORE( WriteLineL( aDes.Mid( curPos, lengthToWrite ) ) );
		    
		iOutputBuffer.SetLength( prefixLength );
				    
		curPos += lengthToWrite;

    	} // end while
    
    } // END Write
Exemplo n.º 4
0
// ---------------------------------------------------------------------------
// From MsearchInfo class.
// CSearchInfoImp::SetFieldInfoL()
// ---------------------------------------------------------------------------
//
void CSearchInfoImp::SetFieldInfoL(const TDesC16& aFieldInfo ,TInfoType aType) 
    
    {
    switch(aType)
	     {
	   	 case EFirstName:
		   	 {
		   	 HBufC16* buf = aFieldInfo.AllocL();
    		 iFirstname.Close();
    		 iFirstname.Assign( buf );
		   	 break;
		   	 }
	   	 case ELastName:
		   	 {
		   	 HBufC16* buf= aFieldInfo.AllocL();
    		 iLastname.Close();
             iLastname.Assign( buf );
		   	 break;	
		   	 }
	   	 case EEmailAddress:
		   	 {
		   	 HBufC16* buf = aFieldInfo.AllocL();
    		 iEmailId.Close();
    		 iEmailId.Assign( buf );
		   	 break;	
		   	 }
	   
	     }
   
    }
Exemplo n.º 5
0
void CTestVwAppUi::ActivateViewL(const TVwsViewId& aViewId,TUid aCustomMessageId,const TDesC16& aCustomMessage)
	{
	HBufC8* narrowMessage=HBufC8::NewLC(aCustomMessage.Size());
	TPtr8 ptr=narrowMessage->Des();
	ptr.Copy((TUint8*)aCustomMessage.Ptr(),aCustomMessage.Size());

	CCoeAppUi::ActivateViewL(aViewId,aCustomMessageId,*narrowMessage);
	CleanupStack::PopAndDestroy(); // narrowMessage.
	}
Exemplo n.º 6
0
/** Finds all the settings that match the specification given by aPartialKey
and aMask, but are either not string values or do not match the given string.
@param aPartialKey
	Contains a bit pattern that all the keys returned must at least partially
	match.
@param aMask
	Has bits set for all the bits in aPartialKey that must match the returned
	keys.
@param aValue
	Settings for the keys found will be settings that either contain values
	that are not strings or strings with value other than aValue.
@param aFoundKeys All the keys found.
	For each key k in aFoundKeys, (k & aMask) == (aPartialKey & aMask) and
	the setting with key k is either not a string value or a string value not
	equal to aValue.
@see FindL()
@return
	KErrNone if successful,
	KErrNotFound if capability check passed but no non-matching items are found,
	plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read policies of all settings found in the source range.
*/
EXPORT_C TInt CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask,
	const TDesC16& aValue, RArray<TUint32>& aFoundKeys)
	{
	TPtrC8 pVal((const TUint8*)aValue.Ptr(), aValue.Length()*2);	
	TRAPD(ret,iImpl->FindSettingsComparisonL(aPartialKey,aMask,pVal,ENotEqual,aFoundKeys));
	if (ret==KErrNoMemory)
		User::LeaveNoMemory();
	return ret;
	}
Exemplo n.º 7
0
/**
	@internalComponent

	Returns the type of the URIs scheme
	
	@param			aScheme	The descriptor with the scheme.
	@return			The scheme type
 */
TUriSchemeType SchemeType(const TDesC16& aScheme)
	{
	// Compares the scheme with both sip and sips
	if (aScheme.CompareF(KSipScheme()) == 0 || aScheme.CompareF(KSipsScheme()) == 0)
		{
		// there's a match so this is a sip scheme
		return ESchemeTypeSip;
		}

	return ESchemeTypeUnknown;
	}
Exemplo n.º 8
0
void TDes8::Copy(const TDesC16 &aDes)
{
	TInt len=aDes.Length();
	SetLength(len);
	const TUint16 *pS=aDes.Ptr();
	const TUint16 *pE=pS+len;
	TUint8 *pT=const_cast<TUint8 *>(Ptr());
	while (pS<pE)
		{
		TUint c=(*pS++);
		if (c>=0x100)
			c=1;
		*pT++=(TUint8)c;
		}
}
// -----------------------------------------------------------------------------
// CSyncMLFilterProperty::AddDefaultValueText16L
// Adds default value for text16 property.
// This is useful only if data type is text16.
// -----------------------------------------------------------------------------
EXPORT_C void CSyncMLFilterProperty::AddDefaultValueText16L( 
                TDesC16& aNewDefaultValue, const TBool aSelected )
	{
	if ( iDataTypeForDefaultValues != ESyncMLDataTypeText16 )
		{
		User::Leave( KErrNotSupported );
		}
	if ( aNewDefaultValue.Length() > iMaxTextLength )
		{
		User::Leave( KErrArgument );
		}
	iDefaultValueText16List.AppendL( aNewDefaultValue.AllocLC() );
	CleanupStack::Pop(); // aNewDefaultValue.AllocLC()
	iDefaultValueSelected.AppendL( aSelected );
	}
void CCatalogsBaseMessageImpl::CompleteAndReleaseL(
    const TDesC16& aOutputData,
    TInt aStatus ) 
    {
    DLTRACEIN(("TDesC16, TInt, handle: %d, this: %x", Handle(), this));
    if ( iSenderLost )
        {
        DLINFO(("Sender was lost, deleting message"));
        delete this;
        DLTRACEOUT((""));
        return;
        }

    TInt clientDescLength( iMessage.GetDesMaxLengthL( 3 ) );

    if ( clientDescLength < aOutputData.Length() )
        {
        if( iMessage.Function() == ECatalogsExternalAllocMessage )
            {
            TInt incompMsgHandle( iSession.WriteToLargerDesL( aOutputData,
                                                              aStatus ) );
                                                              
            TBuf16<KCatalogsMinimumAllocSize> internalMsg(
                                               KCatalogsMinimumAllocLength );
            
            internalMsg.Num( incompMsgHandle );
            internalMsg.Append( KCatalogsTooSmallDescMsgElementDivider );
            internalMsg.AppendNum( aOutputData.Length() );

            TRAPD( error, iMessage.WriteL( KOutputSlot, internalMsg ) );
            if ( error != KErrNone )
                {
                iSession.RemoveIncompleteMessage( incompMsgHandle );
                User::Leave( error );
                }
            }

        iMessage.Complete( KCatalogsErrorTooSmallDescriptor );
        }
    else
        {
        iMessage.WriteL( KOutputSlot, aOutputData );
        iMessage.Complete( aStatus );
        }
        
    delete this;
    DLTRACEOUT((""));
    }
Exemplo n.º 11
0
// -----------------------------------------------------------------------------
// CSatNotifySendSs::CreateTerminalRespL
// Constructs SendSs specific part of terminal response and calls 
// DOS to send the actual message.
// -----------------------------------------------------------------------------
//
TInt CSatNotifySendSs::CreateTerminalRespL
        ( 
        TUint8 aPCmdNumber,        
        TUint8 aGeneralResult,      
        const TDesC16& aAdditionalInfo
		)
    {
	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYSENDSS_CREATETERMINALRESPL_1, "CSAT:: CSatNotifySendSs::CreateTerminalRespL");
    // Create and append response data
    TTlv tlvSpecificData;
    tlvSpecificData.AddTag( KTlvResultTag );    
	// Append general result
    tlvSpecificData.AddByte( aGeneralResult );
	for (TInt i = 0; i < aAdditionalInfo.Length(); i++ )
		{
		tlvSpecificData.AddByte( static_cast<TUint8>( aAdditionalInfo[i] ) );
		}
		
    // Prepare data
    iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
    TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
    // Pack data
    CSatDataPackage dataPackage;
	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
    // Forward request to the DOS
    return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
		ESatTerminalRsp, &dataPackage );
    }
Exemplo n.º 12
0
inline void CPppMsChap::NTChallengeResponseL(const TDesC8& aChallenge,
					     const TDesC16& aPassword,
					     TDes8& aResponse)
/**
   Computes a MS-CHAP Windows NT compatible Challenge Response.
   @param aChallenge [in] A MS-CHAP Challenge (8 octets).
   @param aPassword [in] The Microsoft Windows NT password (0 to 256
   Unicode char).
   @param aResponse [out] The MS-CHAP Windows NT compatible Challenge
   Response (24 octets).
   @note This function implements the NTChallengeResponse routine
   specified in RFC 2433.
   @internalComponent
*/
	{
	ASSERT(aChallenge.Length() == KPppMsChapChallengeSize);
	ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength);
	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);

	HBufC8* paddedPasswordHashBuf =
			HBufC8::NewLC(KPppMsChapPaddedHashSize);
	TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des());

	paddablePasswordHash.SetLength(KPppMsChapHashSize);
	NtPasswordHashL(aPassword, paddablePasswordHash);

	ChallengeResponseL(aChallenge, 
			paddablePasswordHash,
			aResponse);

	CleanupStack::PopAndDestroy(paddedPasswordHashBuf);
	ASSERT(aResponse.Length() == KPppMsChapNTResponseSize);
	}
Exemplo n.º 13
0
// -----------------------------------------------------------------------------
// Sets poly1D points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPoints1DL( const TDesC16& aPointString )
    {
    TInt coordCount = aPointString.Length();

    if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
        User::Leave(KErrArgument);

    iPointCount = coordCount >> 1;
    iPoints = new (ELeave) TPolyPoint[iPointCount];

    iPoints[0].iX = aPointString[0];
    iPoints[0].iY = aPointString[1];

    TUint16 oldX = iPoints[0].iX;

    // parse numbers from the descriptor
    for (TInt i = 1; i < iPointCount; i++) // first point already set
        {
        iPoints[i].iX = aPointString[i*2];
        iPoints[i].iY = aPointString[i*2+1];

        if (iPoints[i].iX < oldX) // points must be in ascending order
            User::Leave(KErrArgument);

        oldX = iPoints[i].iX;
        }
    }
Exemplo n.º 14
0
// -----------------------------------------------------------------------------
// Sets poly points.
// -----------------------------------------------------------------------------
//
void CAknsAlPolyBase::SetPolyPointsL( const TDesC16& aPointString )
    {
    TInt coordCount = aPointString.Length();

    if ((coordCount & 0x1) || coordCount < 4) // odd number or too few point coordinates
        {
        RDebug::Printf("%s, line %d, ERROR: Illegal coordinate count", __FILE__, __LINE__);
        User::Leave(KErrArgument);
        }

    iPointCount = coordCount >> 1;
    iPoints = new (ELeave) TPolyPoint[iPointCount];

    iPoints[0].iX = aPointString[0];
    iPoints[0].iY = aPointString[1];

    TUint16 oldX = iPoints[0].iX;
    TUint16 oldY = iPoints[0].iY;

    // parse numbers from the descriptor
    for (TInt i = 1; i < iPointCount; i++) // first point already set
        {
        iPoints[i].iX = aPointString[i*2];
        iPoints[i].iY = aPointString[i*2+1];

        if (oldX == iPoints[i].iX && oldY == iPoints[i].iY)
            {
            RDebug::Printf("%s, line %d, ERROR: subsequent coordinates cannot be equal", __FILE__, __LINE__);
            User::Leave(KErrArgument);
            }

        oldX = iPoints[i].iX;
        oldY = iPoints[i].iY;
        }
    }
Exemplo n.º 15
0
void CT_ISO2022JP1_2::TestSplittingConvertingFromUnicodeToIso2022Jp(
                CCnvCharacterSetConverter& aCharacterSetConverter,
                TInt aMaximumLengthLowerLimit,
                TInt aMaximumLengthUpperLimit,
                TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit,
                const TDesC8& aExpectedFirstPartOfIso2022Jp,
                const TDesC8& aExpectedSecondPartOfIso2022Jp,
                const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp "));
	test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit);
	test(aMaximumLengthUpperLimit<=KBufferLength);
	TUint8 iso2022JpBuffer[KBufferLength];
	for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i)
		{
		TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i);
		test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit);
		test(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp);
		TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0);
		test(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0);
		TBuf16<KBufferLength> generatedSecondPartOfUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0);
		generatedUnicode.Append(generatedSecondPartOfUnicode);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
// ---------------------------------------------------------------------------
// From MPresentityGroupInfo class.
// CPresentityGroupInfoImp::SetGroupDisplayNameL()
// ---------------------------------------------------------------------------
//
void CPresentityGroupInfoImp::SetGroupDisplayNameL( 
    const TDesC16& aDisplayName )
    {
    HBufC16* displayNameBuf = aDisplayName.AllocL();
    iDisplayName.Close();
    iDisplayName.Assign( displayNameBuf );
    }
Exemplo n.º 17
0
EXPORT_C void TcLog::Write( const TDesC16& aBuf )
	{
	// Convert to narrow
	TBuf8< KTcBufferSize > buf;
	buf.Copy( aBuf.Left( KTcBufferSize ) );
	Write( buf );
	}
// -----------------------------------------------------------------------------
void CPresenceCacheBuddyInfo::SetAnyFieldL( 
    const TDesC16& aKey,
    const TDesC8& aValue )
    {
    if( NPresenceCacheFieldName::KExpiry().CompareF( aKey ) == 0 )
        {
        TPckg<TInt64> expiryPck( iExpiryTime );
        expiryPck.Copy( aValue );
        // write also to key-value map
        }
    
    // Remove old values first
    RemoveField( aKey );    
    
    HBufC8* valueBuffer = aValue.AllocLC();      
    HBufC* keyBuffer = aKey.AllocLC();  
    
    TInt insertPos = iIds.Find(0);
    if ( insertPos < 0 )
        {
        insertPos = iIds.Count();
        iIds.Append( keyBuffer );
        iValues.Append( valueBuffer );
        }
    else
        {
        iIds[insertPos] = keyBuffer;
        iValues[insertPos] = valueBuffer;
        }
    
    iHashMap.InsertL( keyBuffer, insertPos  ); 
    
    CleanupStack::Pop( keyBuffer );
    CleanupStack::Pop( valueBuffer );    
    }
TBool TUriShortcutParser16::HasScheme( const TDesC16& aUri )
{
    int posSchemeComponentDelimiter = aUri.Locate( KSchemeComponentDelimiter );

    if ( posSchemeComponentDelimiter > 0 )
    {
        int posOpeningSquareBracket = aUri.Locate( KOpeningSquareBracket );

        if ( posOpeningSquareBracket == KErrNotFound  || posOpeningSquareBracket > posSchemeComponentDelimiter )
        {
            //scheme present
            return ETrue;
        }
    }
    return EFalse;
}
Exemplo n.º 20
0
void CUpnpHttpFileAccess::ConstructL( CUpnpHttpSession* aSession,
                                      const TDesC16& aFilename )
{
    LOGS1(
        "%i, CUpnpHttpFileAccess::ConstructL(CUpnpHttpSession*, TDesC16&)",
        this );

    User::LeaveIfError(iFsSession.Connect());
    iFileToServe = aFilename.AllocL();

    TInt error =  0;
    iPosInFile = 0;
    iHeaderLength = 0;
    iSession = aSession;
    if (iSession->OverwriteExisting() && !iSession->SaveAtOffset())
    {
        error = iFile.Replace(iFsSession, *iFileToServe, EFileWrite
                              | EFileShareAny);
        User::LeaveIfError(error);
    }
    else if (iSession->OverwriteExisting() && iSession->SaveAtOffset())
    {
        error = iFile.Open(iFsSession, *iFileToServe, EFileWrite
                           | EFileShareAny);
        if (error != KErrNotFound)
        {
            TInt size = 0;
            error = iFile.Size(size);
            if (size >= (iSession->Offset()))
            {
                iPosInFile = iSession->Offset();
            }
            else
            {
                iFile.Close();
                error = iFile.Replace(iFsSession, *iFileToServe, EFileWrite
                                      | EFileShareAny);
                User::LeaveIfError(error);
            }
        }
        else
        {
            error = iFile.Create(iFsSession, *iFileToServe, EFileWrite
                                 | EFileShareAny);
            User::LeaveIfError(error);
        }
    }
    else
    {
        error = iFile.Open(iFsSession, *iFileToServe, EFileWrite
                           | EFileShareAny);
        if (error == KErrNotFound)
        {
            error = iFile.Create(iFsSession, *iFileToServe, EFileWrite
                                 | EFileShareAny);
            User::LeaveIfError(error);
        }
    }
}
Exemplo n.º 21
0
EXPORT_C  void CPTPIPInitCmdAck::SetDeviceFriendlyName(TDesC16& aName)
{
	OstTraceFunctionEntry0( CPTPIPINITCMDACK_SETDEVICEFRIENDLYNAME_ENTRY );
	if(KErrNone == iBuffer.Create(aName,aName.Length()+KMTPNullCharLen))
		{
		iBuffer.Append(KMTPNullChar);
		}
}    
Exemplo n.º 22
0
/**
@SYMTestCaseID          SYSLIB-CHARCONV-CT-0535
@SYMTestCaseDesc        Tests for truncated conversion from Unicode to EucJpPacked
@SYMTestPriority        Medium
@SYMTestActions         Tests for truncated conversion from Unicode to EucJpPacked and back to Unicode
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void CT_EUCJP_PACKED_2::TestTruncatedConversionFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0535 "));
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
		{
		TBuf8<KBufferLength> generatedEucJpPacked;
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedEucJpPacked, aOriginalUnicode.Left(i));
		test(returnValue>=0);
		TBuf8<KBufferLength> generatedsecondPartOfEucJpPacked;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfEucJpPacked, aOriginalUnicode.Mid(i-returnValue))==0);
		generatedEucJpPacked.Append(generatedsecondPartOfEucJpPacked);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedEucJpPacked, state)==0);
		test(generatedUnicode==aOriginalUnicode);
		}
	}
// -----------------------------------------------------------------------------
// CSyncMLFilterProperty::SetQueryValueText16L
// Sets query value for text16 property.
// This is useful only if data type is text16 and if query value can be used.
// This method also selects query value.
// -----------------------------------------------------------------------------
EXPORT_C void
            CSyncMLFilterProperty::SetQueryValueText16L( const TDesC16& aValue )
	{
	if ( iDataTypeForQueryValue != ESyncMLDataTypeText16 || !iCanUseQueryValue )
		{
		User::Leave( KErrNotSupported );
		}
	if ( aValue.Length() > iMaxTextLength )
		{
		User::Leave( KErrArgument );
		}

	delete iQueryValueText16;
	iQueryValueText16 = NULL;
	iQueryValueText16 = aValue.AllocL();
	iQueryValueSelected = ETrue;
	}
Exemplo n.º 24
0
void TEnvVar::ConstructL(const TDesC16& aName, const wchar_t* aValue)
	{
	TPtrC16 valueZ = ValuePtr(aValue);
	HBufC16* valueCopy = valueZ.AllocLC();
	iName = aName.AllocL();
	iValue = valueCopy;
	CleanupStack::Pop();
	}
Exemplo n.º 25
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;
    }
/** Gets a matching scheme for the prefix contained in the URI.

@param aUri descriptor to URI
@return Scheme
@panic KErrBadName URI should contain a '.'
*/
const TPtrC16  TUriShortcutParser16::MatchingScheme( const TDesC16& aUri ) const
{
    TInt pos = aUri.Locate( KSeparatorDot );

    //make sure it contains at least one '.'
    __ASSERT_DEBUG( pos > 0 ,User::Panic( KPanicDescriptor,KErrBadName ) );

    TPtrC16 prefix( aUri.Left( pos ) );
    TPtrC16 scheme ( DefaultScheme() );

    if ( KWww().CompareF( prefix ) == 0 )
    {
        scheme.Set( KHttp() );
    }
    else if ( KFtp().CompareF( prefix ) == 0 )
    {
        scheme.Set( KFtp() );
    }
    else if( CheckUncommonSchemes() )
    {

        if ( KGopher().CompareF( prefix ) == 0 )
        {
            scheme.Set( KGopher() );
        }
        else if ( KTelnet().CompareF( prefix ) == 0 )
        {
            scheme.Set( KTelnet() );
        }
        else if ( KWais().CompareF( prefix ) == 0 )
        {
            scheme.Set( KWais() );
        }
        else if ( KProspero().CompareF( prefix ) == 0 )
        {
            scheme.Set( KProspero() );
        }
        else if ( KNews().CompareF( prefix ) == 0 || KNntp().CompareF( prefix ) == 0 )
        {
            scheme.Set( KNntp() );
        }
    }

    return scheme;
}
Exemplo n.º 27
0
//---------------------------------------------------------------------
//
//---------------------------------------------------------------------	
CLogEntry::CLogEntry(const TDesC16& aMsg, TInt aNbrArg, TInt aArg1, TInt aArg2, TInt aArg3, TInt aArg4) :  iNbrArgs(aNbrArg), 
					iArg1(aArg1), iArg2(aArg2), iArg3(aArg3), iArg4(aArg4) 
	{
	iMsg = HBufC16::New(aMsg.Length());
	if(iMsg)
	    {
    	(*iMsg) = aMsg;
	    }
	}	  
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CNcdConfigurationParser::ParseL( const TDesC16& aData )
    {
    DLTRACEIN(("16-bit parse, length=%d",aData.Length()));
    HBufC8* utf8 = NcdProtocolUtils::ConvertUnicodeToUtf8L( aData );
    CleanupStack::PushL( utf8 );
    ParseL( *utf8 );
    CleanupStack::PopAndDestroy( utf8 );
    
    }
Exemplo n.º 29
0
EXPORT_C int Tlitc16ToChar(const TDesC16& aSrc, char* aDes, int& n_size)
{
    unsigned int ilen = 0;
    int retval = ESuccess;
    ilen = aSrc.Length();
    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 + 1;
    	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, temp16String, ilen*2))
	{
	     aDes[ilen*2] = '\0';    
	}
	else 
	{
		retval = EInvalidWCSSequence;
	}
	
	delete []temp16String;
	return retval;
}
Exemplo n.º 30
0
void CT_ISO2022JP1_2::TestTruncatedConversionFromUnicodeToIso2022Jp(
                CCnvCharacterSetConverter& aCharacterSetConverter,
                const TDesC16& aOriginalUnicode)
	{
	INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp "));
	for (TInt i=aOriginalUnicode.Length(); i>=0; --i)
		{
		TBuf8<KBufferLength> generatedIso2022Jp;
		const TInt returnValue=aCharacterSetConverter.ConvertFromUnicode(generatedIso2022Jp, aOriginalUnicode.Left(i));
		test(returnValue>=0);
		TBuf8<KBufferLength> generatedsecondPartOfIso2022Jp;
		test(aCharacterSetConverter.ConvertFromUnicode(generatedsecondPartOfIso2022Jp, aOriginalUnicode.Mid(i-returnValue))==0);
		generatedIso2022Jp.Append(generatedsecondPartOfIso2022Jp);
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TBuf16<KBufferLength> generatedUnicode;
		test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedIso2022Jp, state)==0);
		test(generatedUnicode==aOriginalUnicode);
		}
	}