utilitylibraries/libutils/src/stringtodescriptor16.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 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)
    31    * -3 is EStringNoData, -9 is EInsufficientSystemMemory)
    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)
   167    * -3 is EStringNoData, -4 is EInvalidPointer, -6 is EUseNewMaxL,
       
   168    * -9 is EInsufficientSystemMemory)
   168    */
   169    */
   169 
   170 
   170 EXPORT_C int StringToHbufc16(string& aSrc , HBufC16* aDes)
   171 EXPORT_C int StringToHbufc16(string& aSrc , HBufC16* aDes)
   171  {
   172  {
   172     int retval = ESuccess;
   173     int retval = ESuccess;
   221    *
   222    *
   222    * @param aSrc is the string to be converted , aDes is the 
   223    * @param aSrc is the string to be converted , aDes is the 
   223    * reference to the descriptor where the result of conversion 
   224    * reference to the descriptor where the result of conversion 
   224    * is stored 
   225    * is stored 
   225    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   226    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   226    * -3 is EStringNoData )
   227    * -3 is EStringNoData, -7 is EInvalidMBSSequence, -9 is EInsufficientSystemMemory)
   227    */
   228    */
   228 
   229 
   229 EXPORT_C int StringToRbuf16(const string& aSrc, RBuf16& aDes)
   230 EXPORT_C int StringToRbuf16(const string& aSrc, RBuf16& aDes)
   230 {
   231 {
   231     int retval = ESuccess;
   232     int retval = ESuccess;
   248     	return EInsufficientMemory;
   249     	return EInsufficientMemory;
   249     }
   250     }
   250 
   251 
   251 	if(minusone != mbstowcs(buf, charString, ilen))
   252 	if(minusone != mbstowcs(buf, charString, ilen))
   252 	{
   253 	{
   253 	    int ret = aDes.Create(ilen);
   254 	  aDes.Copy((const unsigned short *)buf, ilen);		
   254 	    if (KErrNone == ret)
   255 	}
   255 	    {
   256 	else
   256 	    	aDes.Copy((const unsigned short *)buf, ilen);	
   257 	{
   257 	    }
   258 	  retval = EInvalidMBSSequence;		
   258 	    else 
       
   259 	    {
       
   260 	        retval = EInsufficientSystemMemory;	
       
   261 	    }
       
   262 		
       
   263 	}
       
   264 	else
       
   265 	{
       
   266 	    retval = EInvalidMBSSequence;
       
   267 		
       
   268 	}
   259 	}
   269 	
   260 	
   270 	delete []buf;
   261 	delete []buf;
   271     return retval;	
   262   return retval;	
   272 }
   263 }