utilitylibraries/libutils/src/wstringtodescriptor8.cpp
changeset 34 5fae379060a7
parent 0 e4d67989cc36
child 57 2efc27d87e1c
equal deleted inserted replaced
31:ce057bb09d0b 34:5fae379060a7
    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 )
    31    * -3 is EStringNoData, -4 is EInvalidPointer, -8 is EInvalidWCSSequence
       
    32    * -9 is EInsufficientSystemMemory)
    32    */
    33    */
    33 
    34 
    34 EXPORT_C int WstringToTbuf8(wstring& aSrc, TDes8& aDes)
    35 EXPORT_C int WstringToTbuf8(wstring& aSrc, TDes8& aDes)
    35 {	
    36 {	
    36     int retval = ESuccess;
    37     int retval = ESuccess;
   241     	return EInsufficientSystemMemory;
   242     	return EInsufficientSystemMemory;
   242     }
   243     }
   243          
   244          
   244 	if(minusone != wcstombs(buf, (const wchar_t*)wcharString, wlen*2))
   245 	if(minusone != wcstombs(buf, (const wchar_t*)wcharString, wlen*2))
   245 	{
   246 	{
   246 	    int ret = aDes.Create(wlen*2);
   247     aDes.Copy((const unsigned char *)buf, wlen*2);	
   247         if (KErrNone == ret)
       
   248         {
       
   249             aDes.Copy((const unsigned char *)buf, wlen*2);	
       
   250         }
       
   251         else 
       
   252         {
       
   253             retval = EInsufficientSystemMemory;	
       
   254         }
       
   255 	}
   248 	}
   256 	else
   249 	else
   257 	{
   250 	{
   258 		retval = EInvalidWCSSequence;
   251 		retval = EInvalidWCSSequence;
   259 	}
   252 	}