utilitylibraries/libutils/src/wstringtodescriptor16.cpp
changeset 34 5fae379060a7
parent 0 e4d67989cc36
child 57 2efc27d87e1c
equal deleted inserted replaced
31:ce057bb09d0b 34:5fae379060a7
    57    * Converts a wstring to a descriptor of type TPtr16
    57    * Converts a wstring to a descriptor of type TPtr16
    58    *
    58    *
    59    * @param aSrc is the wstring to be converted , aDes is the 
    59    * @param aSrc is the wstring to be converted , aDes is the 
    60    * reference to the descriptor where the result of conversion 
    60    * reference to the descriptor where the result of conversion 
    61    * is stored 
    61    * is stored 
    62    * @return Status code (0 is ESuccess, -3 is EStringNoData)
    62    * @return Status code (0 is ESuccess, -3 is EStringNoData, -1 is EInsufficientMemory)
    63    */
    63    */
    64 
    64 
    65 EXPORT_C int WstringToTptr16(wstring& aSrc, TPtr16& aDes )
    65 EXPORT_C int WstringToTptr16(wstring& aSrc, TPtr16& aDes )
    66 {
    66 {
    67     const wchar_t* wcharString = aSrc.c_str();
    67     const wchar_t* wcharString = aSrc.c_str();
   112    *
   112    *
   113    * @param aSrc is the Wstring to be converted , aDes is the 
   113    * @param aSrc is the Wstring to be converted , aDes is the 
   114    * reference to the descriptor where the result of conversion 
   114    * reference to the descriptor where the result of conversion 
   115    * is stored 
   115    * is stored 
   116    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   116    * @return Status code (0 is ESuccess, -1 is EInsufficientMemory, 
   117    * -3 is EStringNoData )
   117    * -3 is EStringNoData, -4 is EInvalidPointer )
   118    */
   118    */
   119 
   119 
   120 EXPORT_C int WstringToHbufc16(wstring& aSrc, HBufC16* aDes)
   120 EXPORT_C int WstringToHbufc16(wstring& aSrc, HBufC16* aDes)
   121 {
   121 {
   122     unsigned int ilendes = 0; 
   122     unsigned int ilendes = 0; 
   166     {
   166     {
   167     	return EStringNoData;
   167     	return EStringNoData;
   168     }
   168     }
   169     
   169     
   170     wlen = wcslen(wcharString);
   170     wlen = wcslen(wcharString);
   171     
   171 
   172     if (KErrNone == aDes.Create(wlen))
   172     aDes.Copy((const unsigned short *)wcharString, wlen);	
   173     {
   173 
   174         aDes.Copy((const unsigned short *)wcharString, wlen);	
   174 	  return retval;
   175     }
       
   176     else 
       
   177     {
       
   178     	retval = EInsufficientSystemMemory;
       
   179     }
       
   180 	
       
   181 	return retval;
       
   182 }
   175 }