utilitylibraries/libutils/src/wstringtodescriptor8.cpp
branchRCL_3
changeset 57 2efc27d87e1c
parent 56 acd3cd4aaceb
equal deleted inserted replaced
56:acd3cd4aaceb 57:2efc27d87e1c
    26    *
    26    *
    27    * @param aSrc is the wstring to be converted , aDes is the 
    27    * @param aSrc is the wstring to be converted , aDes is the 
    28    * reference to the descriptor where the result of conversion 
    28    * reference to the descriptor where the result of conversion 
    29    * is stored 
    29    * is stored 
    30    * @return Status code (0 is ESuccess,-1 is EInsufficientMemory,
    30    * @return Status code (0 is ESuccess,-1 is EInsufficientMemory,
    31    * -3 is EStringNoData, -4 is EInvalidPointer, -8 is EInvalidWCSSequence
    31    * -3 is EStringNoData, -4 is EInvalidPointer )
    32    * -9 is EInsufficientSystemMemory)
       
    33    */
    32    */
    34 
    33 
    35 EXPORT_C int WstringToTbuf8(wstring& aSrc, TDes8& aDes)
    34 EXPORT_C int WstringToTbuf8(wstring& aSrc, TDes8& aDes)
    36 {	
    35 {	
    37     int retval = ESuccess;
    36     int retval = ESuccess;
   242     	return EInsufficientSystemMemory;
   241     	return EInsufficientSystemMemory;
   243     }
   242     }
   244          
   243          
   245 	if(minusone != wcstombs(buf, (const wchar_t*)wcharString, wlen*2))
   244 	if(minusone != wcstombs(buf, (const wchar_t*)wcharString, wlen*2))
   246 	{
   245 	{
   247     aDes.Copy((const unsigned char *)buf, wlen*2);	
   246 	    int ret = aDes.Create(wlen*2);
       
   247         if (KErrNone == ret)
       
   248         {
       
   249             aDes.Copy((const unsigned char *)buf, wlen*2);	
       
   250         }
       
   251         else 
       
   252         {
       
   253             retval = EInsufficientSystemMemory;	
       
   254         }
   248 	}
   255 	}
   249 	else
   256 	else
   250 	{
   257 	{
   251 		retval = EInvalidWCSSequence;
   258 		retval = EInvalidWCSSequence;
   252 	}
   259 	}