Changed to use char* for charset instead of nsString& for i18n functions, bug 108932, r=ducarroz,sr=sspitzer.

This commit is contained in:
nhotta%netscape.com 2001-11-15 02:00:32 +00:00
parent 14ef1dc652
commit a1e7be4688
16 changed files with 74 additions and 108 deletions

View File

@ -602,7 +602,7 @@ nsresult nsMsgSearchAdapter::EncodeImapTerm (nsIMsgSearchTerm *term, PRBool real
useQuotes = !reallyDredd ||
(nsAutoString(convertedValue).FindChar((PRUnichar)' ') != -1);
// now convert to char* and escape quoted_specials
nsresult rv = ConvertFromUnicode(nsAutoString(destCharset), nsAutoString(convertedValue), &value);
nsresult rv = ConvertFromUnicode(NS_ConvertUCS2toUTF8(destCharset).get(), nsAutoString(convertedValue), &value);
if (NS_SUCCEEDED(rv) && value)
{
char *oldValue = value;

View File

@ -845,10 +845,8 @@ nsresult nsMsgSearchTerm::MatchString (const char *stringToMatch,
n_str = m_value.string;
if (charset != nsnull)
{
nsAutoString srcCharset;
srcCharset.AssignWithConversion(charset);
nsString out;
ConvertToUnicode(srcCharset, stringToMatch ? stringToMatch : "", out);
ConvertToUnicode(charset, stringToMatch ? stringToMatch : "", out);
utf8 = ToNewUTF8String(out);
}
}

View File

@ -660,7 +660,6 @@ nsMessenger::SaveAttachment(const char * contentType, const char * url,
nsCOMPtr<nsIFilePicker> filePicker =
do_CreateInstance("@mozilla.org/filepicker;1", &rv);
char * unescapedDisplayName = nsnull;
nsAutoString tempStr;
PRInt16 dialogResult;
nsCOMPtr<nsILocalFile> localFile;
nsCOMPtr<nsIFileSpec> fileSpec;
@ -685,17 +684,13 @@ nsMessenger::SaveAttachment(const char * contentType, const char * url,
The display name is in UTF-8 because it has been escaped from JS
*/
rv = ConvertToUnicode(NS_LITERAL_STRING("UTF-8"), unescapedDisplayName, tempStr);
if (NS_SUCCEEDED(rv))
{
filePicker->Init(
nsnull,
GetString(NS_LITERAL_STRING("Save Attachment").get()),
nsIFilePicker::modeSave
);
filePicker->SetDefaultString(tempStr.get());
filePicker->AppendFilters(nsIFilePicker::filterAll);
}
filePicker->Init(
nsnull,
GetString(NS_LITERAL_STRING("Save Attachment").get()),
nsIFilePicker::modeSave
);
filePicker->SetDefaultString(NS_ConvertUTF8toUCS2(unescapedDisplayName).get());
filePicker->AppendFilters(nsIFilePicker::filterAll);
nsCRT::free(unescapedDisplayName);
filePicker->Show(&dialogResult);
@ -731,7 +726,6 @@ nsMessenger::SaveAllAttachments(PRUint32 count,
nsCOMPtr<nsIFileSpec> fileSpec;
nsXPIDLCString dirName;
char *unescapedUrl = nsnull, *unescapedName = nsnull, *tempCStr = nsnull;
nsAutoString tempStr;
nsSaveAllAttachmentsState *saveState = nsnull;
PRInt16 dialogResult;
@ -763,9 +757,7 @@ nsMessenger::SaveAllAttachments(PRUint32 count,
nsUnescape(unescapedUrl);
unescapedName = PL_strdup(displayNameArray[0]);
nsUnescape(unescapedName);
rv = ConvertToUnicode(NS_LITERAL_STRING("UTF-8"), unescapedName, tempStr);
if (NS_FAILED(rv)) goto done;
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), tempStr,
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), NS_ConvertUTF8toUCS2(unescapedName),
&tempCStr);
if (NS_FAILED(rv)) goto done;
PR_FREEIF(unescapedName);
@ -1644,7 +1636,7 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
if (m_outputFormat.EqualsWithConversion(TEXT_PLAIN))
{
ConvertBufToPlainText(m_msgBuffer);
rv = nsMsgI18NSaveAsCharset(TEXT_PLAIN, NS_LossyConvertUCS2toASCII(nsMsgI18NFileSystemCharset()).get(),
rv = nsMsgI18NSaveAsCharset(TEXT_PLAIN, nsMsgI18NFileSystemCharset(),
m_msgBuffer.get(), &conBuf);
if ( NS_SUCCEEDED(rv) && (conBuf) )
conLength = nsCRT::strlen(conBuf);
@ -1677,7 +1669,6 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
{
char * unescapedUrl = nsnull, * unescapedName = nsnull,
* tempCStr = nsnull;
nsAutoString tempStr;
nsSaveAllAttachmentsState *state = m_saveAllAttachmentsState;
PRUint32 i = state->m_curIndex;
nsCOMPtr<nsIFileSpec> fileSpec;
@ -1689,9 +1680,7 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
nsUnescape(unescapedUrl);
unescapedName = PL_strdup(state->m_displayNameArray[i]);
nsUnescape(unescapedName);
rv = ConvertToUnicode(NS_LITERAL_STRING("UTF-8"), unescapedName, tempStr);
if (NS_FAILED(rv)) goto done;
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), tempStr,
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), NS_ConvertUTF8toUCS2(unescapedName),
&tempCStr);
if (NS_FAILED(rv)) goto done;
PR_FREEIF(unescapedName);

View File

@ -217,7 +217,7 @@ nsresult nsMsgI18NConvertToUnicode(const nsCString& aCharset,
}
// Convert an unicode string to a C string with a given charset.
nsresult ConvertFromUnicode(const nsAString& aCharset,
nsresult ConvertFromUnicode(const char* aCharset,
const nsString& inString,
char** outCString)
{
@ -237,21 +237,15 @@ nsresult ConvertFromUnicode(const nsAString& aCharset,
}
// Note: this will hide a possible error when the unicode text may contain more than one charset.
// (e.g. Latin1 + Japanese). Use nsMsgI18NSaveAsCharset instead to avoid that problem.
else if (aCharset.IsEmpty() ||
Compare(aCharset,
NS_LITERAL_STRING("us-ascii"),
nsCaseInsensitiveStringComparator()) == 0 ||
Compare(aCharset,
NS_LITERAL_STRING("ISO-8859-1"),
nsCaseInsensitiveStringComparator()) == 0) {
else if (!*aCharset ||
!nsCRT::strcasecmp("us-ascii", aCharset) ||
!nsCRT::strcasecmp("ISO-8859-1", aCharset)) {
*outCString = ToNewCString(inString);
return (NULL == *outCString) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
return *outCString ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
else if (Compare(aCharset,
NS_LITERAL_STRING("UTF-8"),
nsCaseInsensitiveStringComparator()) == 0) {
else if (!nsCRT::strcasecmp("UTF-8", aCharset)) {
*outCString = ToNewUTF8String(inString);
return (NULL == *outCString) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
return *outCString ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
nsresult res;
@ -260,8 +254,7 @@ nsresult ConvertFromUnicode(const nsAString& aCharset,
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr <nsIAtom> charsetAtom;
res = ccm2->GetCharsetAtom(PromiseFlatString(aCharset).get(),
getter_AddRefs(charsetAtom));
res = ccm2->GetCharsetAtom(NS_ConvertASCIItoUCS2(aCharset).get(), getter_AddRefs(charsetAtom));
NS_ENSURE_SUCCESS(res, res);
// get an unicode converter
@ -300,7 +293,7 @@ nsresult ConvertFromUnicode(const nsAString& aCharset,
}
// Convert a C string to an unicode string.
nsresult ConvertToUnicode(const nsAString& aCharset,
nsresult ConvertToUnicode(const char* aCharset,
const char* inCString,
nsString& outString)
{
@ -317,13 +310,9 @@ nsresult ConvertToUnicode(const nsAString& aCharset,
outString.Truncate();
return NS_OK;
}
else if (aCharset.IsEmpty() ||
Compare(aCharset,
NS_LITERAL_STRING("us-ascii"),
nsCaseInsensitiveStringComparator()) == 0 ||
Compare(aCharset,
NS_LITERAL_STRING("ISO-8859-1"),
nsCaseInsensitiveStringComparator()) == 0) {
else if (!*aCharset ||
!nsCRT::strcasecmp("us-ascii", aCharset) ||
!nsCRT::strcasecmp("ISO-8859-1", aCharset)) {
outString.AssignWithConversion(inCString);
return NS_OK;
}
@ -334,8 +323,7 @@ nsresult ConvertToUnicode(const nsAString& aCharset,
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr <nsIAtom> charsetAtom;
res = ccm2->GetCharsetAtom(PromiseFlatString(aCharset).get(),
getter_AddRefs(charsetAtom));
res = ccm2->GetCharsetAtom(NS_ConvertASCIItoUCS2(aCharset).get(), getter_AddRefs(charsetAtom));
NS_ENSURE_SUCCESS(res, res);
// get an unicode converter
@ -385,22 +373,25 @@ const char *msgCompHeaderInternalCharset()
}
// Charset used by the file system.
const nsString& nsMsgI18NFileSystemCharset()
const char * nsMsgI18NFileSystemCharset()
{
/* Get a charset used for the file. */
static nsString aPlatformCharset;
static nsCAutoString fileSystemCharset;
if (aPlatformCharset.Length() < 1)
if (fileSystemCharset.Length() < 1)
{
nsresult rv;
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, aPlatformCharset);
if (NS_SUCCEEDED(rv)) {
nsAutoString charset;
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName, charset);
fileSystemCharset.AssignWithConversion(charset);
}
if (NS_FAILED(rv))
aPlatformCharset.AssignWithConversion("ISO-8859-1");
fileSystemCharset.Assign("ISO-8859-1");
}
return aPlatformCharset;
return fileSystemCharset.get();
}
// MIME encoder, output string should be freed by PR_FREE
@ -409,7 +400,7 @@ char * nsMsgI18NEncodeMimePartIIStr(const char *header, const char *charset, PRB
// No MIME, convert to the outgoing mail charset.
if (PR_FALSE == bUseMime) {
char *convertedStr;
if (NS_SUCCEEDED(ConvertFromUnicode(NS_ConvertASCIItoUCS2(charset), NS_ConvertUTF8toUCS2(header), &convertedStr)))
if (NS_SUCCEEDED(ConvertFromUnicode(charset, NS_ConvertUTF8toUCS2(header), &convertedStr)))
return (convertedStr);
else
return PL_strdup(header);

View File

@ -112,7 +112,7 @@ NS_MSG_BASE const char *msgCompHeaderInternalCharset(void);
*
* @return File system charset name.
*/
NS_MSG_BASE const nsString& nsMsgI18NFileSystemCharset(void);
NS_MSG_BASE const char * nsMsgI18NFileSystemCharset(void);
/**
* Return mail/news default send charset.
@ -153,7 +153,7 @@ NS_MSG_BASE nsresult nsMsgI18NConvertToUnicode(const nsCString& aCharset,
* @param outCString [OUT] Output C string, need PR_FREE.
* @return nsresult.
*/
NS_MSG_BASE nsresult ConvertFromUnicode(const nsAString& aCharset,
NS_MSG_BASE nsresult ConvertFromUnicode(const char* aCharset,
const nsString& inString,
char** outCString);
@ -165,7 +165,7 @@ NS_MSG_BASE nsresult ConvertFromUnicode(const nsAString& aCharset,
* @param outString [OUT] Output unicode string.
* @return nsresult.
*/
NS_MSG_BASE nsresult ConvertToUnicode(const nsAString& aCharset,
NS_MSG_BASE nsresult ConvertToUnicode(const char* aCharset,
const char* inCString,
nsString& outString);

View File

@ -287,7 +287,7 @@ nsresult NS_MsgCreatePathStringFromFolderURI(const char *folderURI, nsCString& p
{
// A file name has to be in native charset, convert from UTF-8.
nsCAutoString oldPath;
const nsString fileCharset(nsMsgI18NFileSystemCharset());
const char *fileCharset = nsMsgI18NFileSystemCharset();
char *nativeString = nsnull;
nsresult rv = ConvertFromUnicode(fileCharset, nsAutoString(NS_ConvertUTF8toUCS2(folderURI)), &nativeString);
if (NS_SUCCEEDED(rv) && nativeString && nativeString[0])

View File

@ -907,8 +907,7 @@ nsMsgAttachmentHandler::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData, P
if (charsetConversion)
{
nsAutoString charset; charset.AssignWithConversion(m_charset);
if (NS_FAILED(ConvertToUnicode(charset, readBuf, sigData)))
if (NS_FAILED(ConvertToUnicode(m_charset, readBuf, sigData)))
sigData.AssignWithConversion(readBuf);
}
else
@ -1076,8 +1075,7 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg)
if (tempfile.is_open())
{
char *tData = nsnull;
nsAutoString charset; charset.AssignWithConversion(m_charset);
if (NS_FAILED(ConvertFromUnicode(charset, conData, &tData)))
if (NS_FAILED(ConvertFromUnicode(m_charset, conData, &tData)))
tData = ToNewCString(conData);
if (tData)
{

View File

@ -76,7 +76,7 @@ nsMsgCompFields::nsMsgCompFields()
prefs->GetBoolPref("mail.request.return_receipt_on", &m_returnReceipt);
prefs->GetIntPref("mail.request.return_receipt", &m_receiptType);
}
m_internalCharSet.AssignWithConversion(msgCompHeaderInternalCharset());
m_internalCharSet.Assign(msgCompHeaderInternalCharset());
// Get the default charset from pref, use this as a mail charset.
char * default_mail_charset = nsMsgI18NGetDefaultMailCharset();
@ -134,7 +134,7 @@ const char* nsMsgCompFields::GetAsciiHeader(MsgHeaderID header)
nsresult nsMsgCompFields::SetUnicodeHeader(MsgHeaderID header, const PRUnichar *value)
{
char* cString;
ConvertFromUnicode(m_internalCharSet, nsAutoString(value), &cString);
ConvertFromUnicode(m_internalCharSet.get(), nsAutoString(value), &cString);
nsresult rv = SetAsciiHeader(header, cString);
PR_Free(cString);
@ -144,7 +144,7 @@ nsresult nsMsgCompFields::SetUnicodeHeader(MsgHeaderID header, const PRUnichar *
nsresult nsMsgCompFields::GetUnicodeHeader(MsgHeaderID header, PRUnichar **_retval)
{
nsString unicodeStr;
ConvertToUnicode(m_internalCharSet, GetAsciiHeader(header), unicodeStr);
ConvertToUnicode(m_internalCharSet.get(), GetAsciiHeader(header), unicodeStr);
*_retval = ToNewUnicode(unicodeStr);
return NS_OK;
}
@ -450,7 +450,7 @@ NS_IMETHODIMP nsMsgCompFields::SetBody(const PRUnichar *value)
if (value)
{
char* cString;
ConvertFromUnicode(m_internalCharSet, nsAutoString(value), &cString);
ConvertFromUnicode(m_internalCharSet.get(), nsAutoString(value), &cString);
m_body = cString;
if (!m_body)
return NS_ERROR_OUT_OF_MEMORY;
@ -462,7 +462,7 @@ NS_IMETHODIMP nsMsgCompFields::GetBody(PRUnichar **_retval)
{
nsString unicodeStr;
const char* cString = GetBody();
ConvertToUnicode(m_internalCharSet, cString, unicodeStr);
ConvertToUnicode(m_internalCharSet.get(), cString, unicodeStr);
*_retval = ToNewUnicode(unicodeStr);
return NS_OK;
@ -584,7 +584,7 @@ NS_IMETHODIMP nsMsgCompFields::SplitRecipients(const PRUnichar *recipients, PRBo
char * addresses;
PRUint32 numAddresses;
if (NS_FAILED(ConvertFromUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), nsAutoString(recipients), &recipientsStr)))
if (NS_FAILED(ConvertFromUnicode(msgCompHeaderInternalCharset(), nsAutoString(recipients), &recipientsStr)))
{
recipientsStr = ToNewCString(nsDependentString(recipients));
}
@ -608,11 +608,11 @@ NS_IMETHODIMP nsMsgCompFields::SplitRecipients(const PRUnichar *recipients, PRBo
rv = parser->MakeFullAddress(msgCompHeaderInternalCharset(), pNames, pAddresses, &fullAddress);
if (NS_SUCCEEDED(rv) && !emailAddressOnly)
{
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress, aRecipient);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), fullAddress, aRecipient);
PR_FREEIF(fullAddress);
}
else
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), pAddresses, aRecipient);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), pAddresses, aRecipient);
if (NS_FAILED(rv))
break;
@ -679,7 +679,7 @@ nsresult nsMsgCompFields::SplitRecipientsEx(const PRUnichar *recipients, nsIMsgR
char * addresses;
PRUint32 numAddresses;
if (NS_FAILED(ConvertFromUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), nsAutoString(recipients), &recipientsStr)))
if (NS_FAILED(ConvertFromUnicode(msgCompHeaderInternalCharset(), nsAutoString(recipients), &recipientsStr)))
{
recipientsStr = ToNewCString(nsDependentString(recipients));
}
@ -704,11 +704,11 @@ nsresult nsMsgCompFields::SplitRecipientsEx(const PRUnichar *recipients, nsIMsgR
rv = parser->MakeFullAddress(msgCompHeaderInternalCharset(), pNames, pAddresses, &fullAddress);
if (NS_SUCCEEDED(rv))
{
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress, aRecipient);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), fullAddress, aRecipient);
PR_FREEIF(fullAddress);
}
else
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), pAddresses, aRecipient);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), pAddresses, aRecipient);
if (NS_FAILED(rv))
return rv;
@ -719,7 +719,7 @@ nsresult nsMsgCompFields::SplitRecipientsEx(const PRUnichar *recipients, nsIMsgR
if (pEmailsArray)
{
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), pAddresses, aRecipient);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), pAddresses, aRecipient);
if (NS_FAILED(rv))
return rv;
rv = pEmailsArray->AppendString(aRecipient.get(), &aBool);

View File

@ -179,7 +179,7 @@ protected:
PRBool m_uuEncodeAttachments;
PRBool m_returnReceipt;
PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */
nsString m_internalCharSet;
nsCString m_internalCharSet;
nsCOMPtr<nsISupports> mSecureCompFields;
};

View File

@ -819,7 +819,7 @@ mime_generate_attachment_headers (const char *type, const char *encoding,
if (real_name)
{
encodedRealName = nsMsgI18NEncodeMimePartIIStr(real_name,
NS_ConvertUCS2toUTF8(nsMsgI18NFileSystemCharset()).get(), nsMsgMIMEGetConformToStandard());
nsMsgI18NFileSystemCharset(), nsMsgMIMEGetConformToStandard());
if (!encodedRealName || !*encodedRealName)
{
/* Let's try one more time using UTF8 */

View File

@ -2815,15 +2815,15 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData)
}
tempFile.close();
nsAutoString sigEncoding;
sigEncoding.AssignWithConversion(nsMsgI18NParseMetaCharset(&fSpec));
nsCAutoString sigEncoding;
sigEncoding.Assign(nsMsgI18NParseMetaCharset(&fSpec));
PRBool removeSigCharset = !sigEncoding.IsEmpty() && m_composeHTML;
//default to platform encoding for signature files w/o meta charset
if (sigEncoding.IsEmpty())
sigEncoding.Assign(nsMsgI18NFileSystemCharset());
if (NS_FAILED(ConvertToUnicode(sigEncoding, readBuf, sigData)))
if (NS_FAILED(ConvertToUnicode(sigEncoding.get(), readBuf, sigData)))
sigData.AssignWithConversion(readBuf);
//remove sig meta charset to allow user charset override during composition
@ -2831,7 +2831,7 @@ nsMsgCompose::LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData)
{
nsAutoString metaCharset;
metaCharset.Assign(NS_LITERAL_STRING("charset="));
metaCharset.Append(sigEncoding);
metaCharset.AppendWithConversion(sigEncoding.get());
PRInt32 metaCharsetOffset = sigData.Find(metaCharset,PR_TRUE,0,-1);
if (metaCharsetOffset != kNotFound)
@ -3520,7 +3520,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList,
if (!fullAddress.IsEmpty())
{
/* We need to convert back the result from UTF-8 to Unicode */
(void)ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress.get(), fullNameStr);
(void)ConvertToUnicode(msgCompHeaderInternalCharset(), fullAddress.get(), fullNameStr);
}
}
if (fullNameStr.IsEmpty())
@ -4242,7 +4242,7 @@ nsMsgMailList::nsMsgMailList(nsString listName, nsString listDescription, nsIAbD
if (!fullAddress.IsEmpty())
{
/* We need to convert back the result from UTF-8 to Unicode */
(void)ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress, mFullName);
(void)ConvertToUnicode(msgCompHeaderInternalCharset(), fullAddress, mFullName);
}
}

View File

@ -2011,20 +2011,14 @@ NS_IMETHODIMP nsImapIncomingServer::FEAlertFromServer(const char *aString, nsIM
whereRealMessage[len] = '.';
}
// the alert string from the server IS UTF-8!!! We must convert it to unicode
// correctly before appending it to our error message string...
nsAutoString unicodeAlertString;
nsAutoString charset;
charset.AppendWithConversion("UTF-8");
ConvertToUnicode(charset, whereRealMessage ? whereRealMessage : aString, unicodeAlertString);
PRUnichar *serverSaidPrefix = nsnull;
GetImapStringByID(IMAP_SERVER_SAID, &serverSaidPrefix);
if (serverSaidPrefix)
{
nsAutoString message(serverSaidPrefix);
message.Append(unicodeAlertString);
// the alert string from the server IS UTF-8!!! We must convert it to unicode
// correctly before appending it to our error message string...
message.Append(NS_ConvertUTF8toUCS2(whereRealMessage ? whereRealMessage : aString));
rv = dialog->Alert(nsnull, message.get());
PR_Free(serverSaidPrefix);

View File

@ -615,7 +615,7 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg)
// resort we'll use the mail defaul charset.
if (! headerVal.Length())
{
headerVal = nsMsgI18NFileSystemCharset();
headerVal.AssignWithConversion(nsMsgI18NFileSystemCharset());
if (! headerVal.Length())
{ // last resort
if (!m_defCharset.Length())

View File

@ -1231,9 +1231,8 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
// convert from PRUnichar* to char* due to not having Rename(PRUnichar*)
// function in nsIFileSpec
const nsString fileCharset(nsMsgI18NFileSystemCharset());
nsXPIDLCString convertedNewName;
if (NS_FAILED(ConvertFromUnicode(fileCharset, nsAutoString(aNewName), getter_Copies(convertedNewName))))
if (NS_FAILED(ConvertFromUnicode(nsMsgI18NFileSystemCharset(), nsAutoString(aNewName), getter_Copies(convertedNewName))))
return NS_ERROR_FAILURE;
nsCAutoString newNameStr(convertedNewName.get());

View File

@ -221,24 +221,21 @@ static PRInt32 INTL_ConvertCharset(const char* from_charset, const char* to_char
nsAutoString outString;
nsAutoString aCharset; aCharset.AssignWithConversion(from_charset);
res = ConvertToUnicode(aCharset, inBuffer, outString);
res = ConvertToUnicode(from_charset, inBuffer, outString);
// known bug in 4.x, it mixes Shift_JIS (or EUC-JP) and ISO-2022-JP in vCard fields
if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) {
if (aCharset.EqualsIgnoreCase("ISO-2022-JP")) {
aCharset.AssignWithConversion("Shift_JIS");
res = ConvertToUnicode(aCharset, inBuffer, outString);
if (!nsCRT::strcasecmp("ISO-2022-JP", from_charset)) {
res = ConvertToUnicode("Shift_JIS", inBuffer, outString);
if (NS_ERROR_MODULE_UCONV == NS_ERROR_GET_MODULE(res)) {
aCharset.AssignWithConversion("EUC-JP");
res = ConvertToUnicode(aCharset, inBuffer, outString);
res = ConvertToUnicode("EUC-JP", inBuffer, outString);
}
}
}
if (NS_SUCCEEDED(res)) {
res = ConvertFromUnicode(NS_ConvertASCIItoUCS2(to_charset), outString, outBuffer);
res = ConvertFromUnicode(to_charset, outString, outBuffer);
if (NS_SUCCEEDED(res)) {
*outLength = nsCRT::strlen(*outBuffer);
}

View File

@ -226,7 +226,7 @@ mime_dump_attachments ( attachmentList );
if (NS_SUCCEEDED(rv) && attachment)
{
nsAutoString nameStr;
rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), curAttachment->real_name, nameStr);
rv = ConvertToUnicode(msgCompHeaderInternalCharset(), curAttachment->real_name, nameStr);
if (NS_FAILED(rv))
nameStr.AssignWithConversion(curAttachment->real_name);
attachment->SetName(nameStr.get());
@ -1756,7 +1756,7 @@ mime_decompose_file_init_fn ( void *stream_closure, MimeHeaders *headers )
//Need some convertion to native file system character set
nsAutoString outStr;
char * fileName = nsnull;
nsresult rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), newAttachment->real_name, outStr);
nsresult rv = ConvertToUnicode(msgCompHeaderInternalCharset(), newAttachment->real_name, outStr);
if (NS_SUCCEEDED(rv))
{
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), outStr, &fileName);