nsAutoString convCharset;
nsCOMPtr<nsICharsetConverterManager2> ccm2 = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_IMETHODIMP nsImportService::SystemStringToUnicode(const char *sysStr, nsString & uniStr){  	nsresult	rv;	if (m_sysCharset.IsEmpty()) {		nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);		if (NS_SUCCEEDED(rv)) 			rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, m_sysCharset);		if (NS_FAILED(rv)) 			m_sysCharset.AssignWithConversion("ISO-8859-1");	}	if (!sysStr) {		uniStr.Truncate();		return( NS_OK);	}  	if (*sysStr == '\0') {		uniStr.Truncate();		return( NS_OK);	}		if (m_sysCharset.IsEmpty() ||		m_sysCharset.EqualsIgnoreCase("us-ascii") ||		m_sysCharset.EqualsIgnoreCase("ISO-8859-1")) {		uniStr.AssignWithConversion( sysStr);		return( NS_OK);	}			if (!m_pDecoder) {		nsAutoString convCharset;		// Resolve charset alias		NS_WITH_SERVICE( nsICharsetAlias, calias, kCharsetAliasCID, &rv); 		if (NS_SUCCEEDED( rv)) {			nsAutoString aAlias( m_sysCharset);			if (aAlias.Length()) {				rv = calias->GetPreferred( aAlias, convCharset);			}		}		if (NS_FAILED( rv)) {			IMPORT_LOG0( "*** Error getting charset alias to convert to uinicode\n");			uniStr.AssignWithConversion( sysStr);			return( rv);		}		NS_WITH_SERVICE( nsICharsetConverterManager, ccm, kCharsetConverterManagerCID, &rv); 		if (NS_SUCCEEDED( rv) && (nsnull != ccm)) {			// get an unicode converter			rv = ccm->GetUnicodeDecoder( &convCharset, &m_pDecoder);		}	    	}	if (m_pDecoder) {		PRInt32		srcLen = PL_strlen( sysStr);		PRUnichar *	unichars;		PRInt32 unicharLength = 0;		rv = m_pDecoder->GetMaxLength( sysStr, srcLen, &unicharLength);		// allocale an output buffer		unichars = (PRUnichar *) PR_Malloc(unicharLength * sizeof(PRUnichar));		if (unichars != nsnull) {			// convert to unicode			rv = m_pDecoder->Convert( sysStr, &srcLen, unichars, &unicharLength);			uniStr.Assign(unichars, unicharLength);			PR_Free(unichars);		}		else			rv = NS_ERROR_OUT_OF_MEMORY;	}		if (NS_FAILED( rv))		uniStr.AssignWithConversion( sysStr);	return( rv);}