зеркало из https://github.com/mozilla/pjs.git
making string conversions explicit
This commit is contained in:
Родитель
e9e31a47c5
Коммит
eddc40fcba
|
@ -765,7 +765,7 @@ convert_and_encode:
|
|||
}
|
||||
// utf-8 to mail charset conversion (or iso-8859-1 in case of us-ascii).
|
||||
PRUnichar *u = NULL;
|
||||
nsAutoString fmt("%s");
|
||||
nsAutoString fmt; fmt.AssignWithConversion("%s");
|
||||
char aChar = begin[len];
|
||||
begin[len] = '\0';
|
||||
u = nsTextFormatter::smprintf(fmt.GetUnicode(), begin);
|
||||
|
@ -1243,13 +1243,13 @@ PRInt32 MimeCharsetConverterClass::Initialize(const char* from_charset, const ch
|
|||
|
||||
NS_ASSERTION(NULL == mEncoder, "No reinitialization allowed.");
|
||||
|
||||
mInputCharset.Assign(from_charset); // remember input charset for a hint
|
||||
mInputCharset.AssignWithConversion(from_charset); // remember input charset for a hint
|
||||
if (mInputCharset.IsEmpty()) {
|
||||
mInputCharset.Assign("ISO-8859-1");
|
||||
mInputCharset.AssignWithConversion("ISO-8859-1");
|
||||
}
|
||||
mOutputCharset.Assign(to_charset); // remember output charset
|
||||
mOutputCharset.AssignWithConversion(to_charset); // remember output charset
|
||||
if (mOutputCharset.IsEmpty()) {
|
||||
mOutputCharset.Assign("UTF-8");
|
||||
mOutputCharset.AssignWithConversion("UTF-8");
|
||||
}
|
||||
mAutoDetect = autoDetect;
|
||||
mMaxNumCharsDetect = maxNumCharsDetect;
|
||||
|
@ -1261,14 +1261,14 @@ PRInt32 MimeCharsetConverterClass::Initialize(const char* from_charset, const ch
|
|||
if (aAlias.Length()) {
|
||||
res = calias->GetPreferred(aAlias, mInputCharset);
|
||||
if (NS_FAILED(res)) {
|
||||
mInputCharset.Assign("ISO-8859-1");
|
||||
mInputCharset.AssignWithConversion("ISO-8859-1");
|
||||
}
|
||||
}
|
||||
aAlias = mOutputCharset;
|
||||
if (aAlias.Length()) {
|
||||
res = calias->GetPreferred(aAlias, mOutputCharset);
|
||||
if (NS_FAILED(res)) {
|
||||
mOutputCharset.Assign("UTF-8");
|
||||
mOutputCharset.AssignWithConversion("UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1349,7 +1349,7 @@ PRInt32 MimeCharsetConverterClass::Convert(const char* inBuffer, const PRInt32 i
|
|||
nsDetectionConfident oConfident;
|
||||
res = mDetector->DoIt(inBuffer, inLength, &oCharset, oConfident);
|
||||
if (NS_SUCCEEDED(res) && (eBestAnswer == oConfident || eSureAnswer == oConfident)) {
|
||||
aCharsetDetected.Assign(oCharset);
|
||||
aCharsetDetected.AssignWithConversion(oCharset);
|
||||
|
||||
// Check if need a conversion.
|
||||
if (!NeedCharsetConversion(aCharsetDetected, mOutputCharset)) {
|
||||
|
|
|
@ -206,8 +206,8 @@ mime_dump_attachments ( attachmentList );
|
|||
if (NS_SUCCEEDED(rv) && spec)
|
||||
{
|
||||
if (attachments.Length())
|
||||
attachments += ',';
|
||||
attachments += spec;
|
||||
attachments.AppendWithConversion(',');
|
||||
attachments.AppendWithConversion(spec);
|
||||
nsCRT::free(spec);
|
||||
spec = nsnull;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static nsString& mime_decode_string(const char* str,
|
|||
{
|
||||
static nsString decodedString;
|
||||
nsString encodedCharset;
|
||||
nsMsgI18NDecodeMimePartIIStr(nsString(str), encodedCharset,
|
||||
nsMsgI18NDecodeMimePartIIStr(NS_ConvertASCIItoUCS2(str), encodedCharset,
|
||||
decodedString, eatContinuations);
|
||||
return decodedString;
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ CreateCompositionFields(const char *from,
|
|||
NS_ADDREF(cFields);
|
||||
|
||||
// Now set all of the passed in stuff...
|
||||
cFields->SetCharacterSet(nsString(charset).GetUnicode());
|
||||
cFields->SetCharacterSet(NS_ConvertASCIItoUCS2(charset).GetUnicode());
|
||||
cFields->SetFrom(mime_decode_string(from).GetUnicode());
|
||||
cFields->SetSubject(mime_decode_string(subject).GetUnicode());
|
||||
cFields->SetReplyTo(mime_decode_string(reply_to).GetUnicode());
|
||||
|
@ -1337,7 +1337,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
|||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::ForwardInline, composeFormat, mdd->identity);
|
||||
else
|
||||
{
|
||||
nsString urlStr(mdd->url_name);
|
||||
nsString urlStr; urlStr.AssignWithConversion(mdd->url_name);
|
||||
fields->SetDraftId(urlStr.GetUnicode());
|
||||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::Draft, composeFormat, mdd->identity);
|
||||
}
|
||||
|
@ -1368,7 +1368,7 @@ mime_parse_stream_complete (nsMIMESession *stream)
|
|||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::ForwardInline, nsIMsgCompFormat::Default, mdd->identity);
|
||||
else
|
||||
{
|
||||
nsString urlStr(mdd->url_name);
|
||||
nsString urlStr; urlStr.AssignWithConversion(mdd->url_name);
|
||||
fields->SetDraftId(urlStr.GetUnicode());
|
||||
CreateTheComposeWindow(fields, newAttachData, nsIMsgCompType::Draft, nsIMsgCompFormat::Default, mdd->identity);
|
||||
}
|
||||
|
@ -1643,7 +1643,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(msgCompHeaderInternalCharset(), newAttachment->real_name, outStr);
|
||||
nsresult rv = ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), newAttachment->real_name, outStr);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), outStr, &fileName);
|
||||
|
|
|
@ -240,7 +240,7 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs)
|
|||
//
|
||||
if (!aAttach->real_name || *aAttach->real_name == 0)
|
||||
{
|
||||
nsString newAttachName = "attachment";
|
||||
nsString newAttachName; newAttachName.AssignWithConversion("attachment");
|
||||
nsresult rv = NS_OK;
|
||||
NS_WITH_SERVICE(nsIMIMEService, mimeFinder, kMimeServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && mimeFinder)
|
||||
|
@ -253,8 +253,8 @@ ValidateRealName(nsMsgAttachmentData *aAttach, MimeHeaders *aHdrs)
|
|||
|
||||
if ( (NS_SUCCEEDED(mimeInfo->FirstExtension(&aFileExtension))) && aFileExtension)
|
||||
{
|
||||
newAttachName.Append(".");
|
||||
newAttachName.Append(aFileExtension);
|
||||
newAttachName.AppendWithConversion(".");
|
||||
newAttachName.AppendWithConversion(aFileExtension);
|
||||
PR_FREEIF(aFileExtension);
|
||||
}
|
||||
}
|
||||
|
@ -1702,7 +1702,7 @@ MimeGetStringByID(PRInt32 stringID)
|
|||
return resultString;
|
||||
else
|
||||
{
|
||||
nsAutoString v("");
|
||||
nsAutoString v;
|
||||
v = ptrv;
|
||||
tempString = v.ToNewUTF8String();
|
||||
}
|
||||
|
@ -1783,7 +1783,7 @@ static int DoLanguageSensitiveFont(MimeObject *obj, const char *prefixName, cons
|
|||
|
||||
// no alias resolution for performance
|
||||
// if we get alias then no font tag to be generated (i think that's acceptable).
|
||||
aCharset.Assign(text->charset);
|
||||
aCharset.AssignWithConversion(text->charset);
|
||||
aCharset.ToLowerCase();
|
||||
|
||||
|
||||
|
@ -1798,7 +1798,7 @@ static int DoLanguageSensitiveFont(MimeObject *obj, const char *prefixName, cons
|
|||
goto done;
|
||||
|
||||
// append the language to the pref string
|
||||
aPrefStr.Append(langGroup);
|
||||
aPrefStr.AppendWithConversion(langGroup);
|
||||
|
||||
nsIPref *aPrefs = GetPrefServiceManager(obj->options);
|
||||
|
||||
|
@ -1817,13 +1817,15 @@ static int DoLanguageSensitiveFont(MimeObject *obj, const char *prefixName, cons
|
|||
nsAutoString tempStr(unicode);
|
||||
PR_FREEIF(unicode);
|
||||
|
||||
rv = nsMsgI18NConvertFromUnicode(aCharset, tempStr, fontName);
|
||||
nsCAutoString charsetCStr;
|
||||
charsetCStr.AssignWithConversion(aCharset);
|
||||
rv = nsMsgI18NConvertFromUnicode(charsetCStr, tempStr, fontName);
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
||||
// get a font size from pref
|
||||
aPrefStr.Assign(prefixSize);
|
||||
aPrefStr.Append(langGroup);
|
||||
aPrefStr.AppendWithConversion(langGroup);
|
||||
rv = aPrefs->GetIntPref(aPrefStr, &fontSize);
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
@ -1882,7 +1884,7 @@ int BeginMailNewsFont(MimeObject *obj)
|
|||
|
||||
if (!text->charset || !(*text->charset))
|
||||
goto done;
|
||||
aCharset.Assign(text->charset);
|
||||
aCharset.AssignWithConversion(text->charset);
|
||||
|
||||
// get a font name from pref, could be non ascii (need charset conversion)
|
||||
// this is not necessary if we insert this tag after the message is converted to UTF-8
|
||||
|
@ -1891,7 +1893,9 @@ int BeginMailNewsFont(MimeObject *obj)
|
|||
goto done;
|
||||
nsAutoString tempStr(unicode);
|
||||
PR_FREEIF(unicode);
|
||||
rv = nsMsgI18NConvertFromUnicode(aCharset, tempStr, fontName);
|
||||
nsCAutoString charsetCStr;
|
||||
charsetCStr.AssignWithConversion(aCharset);
|
||||
rv = nsMsgI18NConvertFromUnicode(charsetCStr, tempStr, fontName);
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ MimeInlineTextPlainFlowed_parse_line (char *line, PRInt32 length, MimeObject *ob
|
|||
if (!skipConversion)
|
||||
{
|
||||
//XXX I18N Converting char* to PRUnichar*
|
||||
nsString strline(linep, (length - (linep - line)) );
|
||||
nsString strline; strline.AssignWithConversion(linep, (length - (linep - line)) );
|
||||
PRUnichar* wresult = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
PRBool whattodo = obj->options->whattodo;
|
||||
|
|
|
@ -305,7 +305,7 @@ MimeInlineTextPlain_parse_line (char *line, PRInt32 length, MimeObject *obj)
|
|||
|
||||
if (!skipConversion)
|
||||
{
|
||||
nsString strline(line, length);
|
||||
nsString strline; strline.AssignWithConversion(line, length);
|
||||
nsresult rv = NS_OK;
|
||||
PRUnichar* wresult = nsnull;
|
||||
PRBool whattodo = obj->options->whattodo;
|
||||
|
|
|
@ -67,18 +67,18 @@ nsMimeConverter::DecodeMimePartIIStr(const nsCString& header,
|
|||
if (nsnull == decodedCstr) {
|
||||
// no decode needed and no default charset was specified
|
||||
if (charset.IsEmpty()) {
|
||||
decodedString.Assign(header);
|
||||
decodedString.AssignWithConversion(header);
|
||||
}
|
||||
else {
|
||||
// no MIME encoded, convert default charset to unicode
|
||||
res = ConvertToUnicode((nsAutoString) charset, header, decodedString);
|
||||
res = ConvertToUnicode(NS_ConvertASCIItoUCS2(charset), header, decodedString);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// assign the charset encoded in MIME header
|
||||
charset.Assign(charsetNameBuffer);
|
||||
// convert MIME charset to unicode
|
||||
res = ConvertToUnicode((nsAutoString) charset, (const char *) decodedCstr, decodedString);
|
||||
res = ConvertToUnicode(NS_ConvertASCIItoUCS2(charset), (const char *) decodedCstr, decodedString);
|
||||
PR_FREEIF(decodedCstr);
|
||||
}
|
||||
return res;
|
||||
|
@ -114,7 +114,7 @@ nsMimeConverter::DecodeMimePartIIStr(const nsString& header,
|
|||
else {
|
||||
// convert MIME charset to unicode
|
||||
nsAutoString decodedStr;
|
||||
res = ConvertToUnicode(nsAutoString(charsetCstr), (const char *) decodedCstr, decodedStr);
|
||||
res = ConvertToUnicode(NS_ConvertASCIItoUCS2(charsetCstr), (const char *) decodedCstr, decodedStr);
|
||||
*decodedString = decodedStr.ToNewUnicode();
|
||||
PR_FREEIF(decodedCstr);
|
||||
}
|
||||
|
|
|
@ -105,17 +105,17 @@ NS_IMETHODIMP nsMsgHeaderParserResult::GetAddressAndName(PRUnichar ** aAddress,
|
|||
nsresult rv = NS_OK;
|
||||
// *yuck* the mime converter interface is requiring us to pass in nsStrings which is forcing
|
||||
// all this extra string copying...we need to fix the interface!
|
||||
nsAutoString charset ("UTF-8");
|
||||
nsAutoString charset; charset.AssignWithConversion("UTF-8");
|
||||
nsXPIDLString unicodeValue;
|
||||
nsAutoString value;
|
||||
if (aAddress)
|
||||
{
|
||||
value = mCurrentAddress;
|
||||
value.AssignWithConversion(mCurrentAddress);
|
||||
rv = mUnicodeConverter->DecodeMimePartIIStr(value, charset, aAddress);
|
||||
}
|
||||
if (aName)
|
||||
{
|
||||
value = mCurrentName;
|
||||
value.AssignWithConversion(mCurrentName);
|
||||
rv = mUnicodeConverter->DecodeMimePartIIStr(value, charset, aName);
|
||||
}
|
||||
if (aFullAddress)
|
||||
|
@ -126,7 +126,7 @@ NS_IMETHODIMP nsMsgHeaderParserResult::GetAddressAndName(PRUnichar ** aAddress,
|
|||
getter_Copies(fullAddress));
|
||||
if (NS_SUCCEEDED(rv) && (const char*)fullAddress)
|
||||
{
|
||||
value.Assign(fullAddress);
|
||||
value.AssignWithConversion(fullAddress);
|
||||
rv = mUnicodeConverter->DecodeMimePartIIStr(value, charset, aFullAddress);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче