utilitylibraries/libutils/src/stringtodescriptor16.cpp
branchRCL_3
changeset 57 2efc27d87e1c
parent 56 acd3cd4aaceb
equal deleted inserted replaced
56:acd3cd4aaceb 57:2efc27d87e1c
    26    *
    26    *
    27    * @param aSrc is the string to be converted , aDes is the 
    27    * @param aSrc is the string 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,n_size specifies the conversion size of the char array 
    29    * is stored,n_size specifies the conversion size of the char array 
    30    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
    30    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
    31    * -3 is EStringNoData, -9 is EInsufficientSystemMemory)
    31    * -3 is EStringNoData)
    32    */
    32    */
    33 EXPORT_C  int StringToTbuf16(string& aSrc, TDes16& aDes)
    33 EXPORT_C  int StringToTbuf16(string& aSrc, TDes16& aDes)
    34 {
    34 {
    35   int retval = ESuccess;
    35   int retval = ESuccess;
    36 	const char* charString = aSrc.c_str();
    36 	const char* charString = aSrc.c_str();
   162    *
   162    *
   163    * @param aSrc is the string to be converted , aDes is the 
   163    * @param aSrc is the string to be converted , aDes is the 
   164    * reference to the descriptor where the result of conversion 
   164    * reference to the descriptor where the result of conversion 
   165    * is stored 
   165    * is stored 
   166    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   166    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   167    * -3 is EStringNoData, -4 is EInvalidPointer, -6 is EUseNewMaxL,
   167    * -3 is EStringNoData)
   168    * -9 is EInsufficientSystemMemory)
       
   169    */
   168    */
   170 
   169 
   171 EXPORT_C int StringToHbufc16(string& aSrc , HBufC16* aDes)
   170 EXPORT_C int StringToHbufc16(string& aSrc , HBufC16* aDes)
   172  {
   171  {
   173     int retval = ESuccess;
   172     int retval = ESuccess;
   222    *
   221    *
   223    * @param aSrc is the string to be converted , aDes is the 
   222    * @param aSrc is the string to be converted , aDes is the 
   224    * reference to the descriptor where the result of conversion 
   223    * reference to the descriptor where the result of conversion 
   225    * is stored 
   224    * is stored 
   226    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   225    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   227    * -3 is EStringNoData, -7 is EInvalidMBSSequence, -9 is EInsufficientSystemMemory)
   226    * -3 is EStringNoData )
   228    */
   227    */
   229 
   228 
   230 EXPORT_C int StringToRbuf16(const string& aSrc, RBuf16& aDes)
   229 EXPORT_C int StringToRbuf16(const string& aSrc, RBuf16& aDes)
   231 {
   230 {
   232     int retval = ESuccess;
   231     int retval = ESuccess;
   249     	return EInsufficientMemory;
   248     	return EInsufficientMemory;
   250     }
   249     }
   251 
   250 
   252 	if(minusone != mbstowcs(buf, charString, ilen))
   251 	if(minusone != mbstowcs(buf, charString, ilen))
   253 	{
   252 	{
   254 	  aDes.Copy((const unsigned short *)buf, ilen);		
   253 	    int ret = aDes.Create(ilen);
   255 	}
   254 	    if (KErrNone == ret)
   256 	else
   255 	    {
   257 	{
   256 	    	aDes.Copy((const unsigned short *)buf, ilen);	
   258 	  retval = EInvalidMBSSequence;		
   257 	    }
       
   258 	    else 
       
   259 	    {
       
   260 	        retval = EInsufficientSystemMemory;	
       
   261 	    }
       
   262 		
       
   263 	}
       
   264 	else
       
   265 	{
       
   266 	    retval = EInvalidMBSSequence;
       
   267 		
   259 	}
   268 	}
   260 	
   269 	
   261 	delete []buf;
   270 	delete []buf;
   262   return retval;	
   271     return retval;	
   263 }
   272 }