зеркало из https://github.com/mozilla/pjs.git
Changed to use unicode converter and related changes.
This commit is contained in:
Родитель
0c6bb06155
Коммит
6b54fa0505
|
@ -127,9 +127,17 @@ nsresult ConvertToUnicode(const nsString aCharset,
|
|||
nsIUnicodeDecoder* decoder = nsnull;
|
||||
PRUnichar *unichars;
|
||||
PRInt32 unicharLength;
|
||||
nsString convCharset;
|
||||
|
||||
// map to converter charset
|
||||
if (aCharset.EqualsIgnoreCase("us-ascii")) {
|
||||
convCharset.SetString("iso-8859-1");
|
||||
}
|
||||
else {
|
||||
convCharset = aCharset;
|
||||
}
|
||||
// get an unicode converter
|
||||
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
|
||||
res = ccm->GetUnicodeDecoder(&convCharset, &decoder);
|
||||
if(NS_SUCCEEDED(res) && (nsnull != decoder)) {
|
||||
PRInt32 srcLen = PL_strlen(inCString);
|
||||
res = decoder->Length(inCString, 0, srcLen, &unicharLength);
|
||||
|
|
|
@ -85,6 +85,9 @@ extern char * INTL_GetDefaultMailCharset(void);
|
|||
extern nsresult ConvertFromUnicode(const nsString aCharset,
|
||||
const nsString inString,
|
||||
char** outCString);
|
||||
extern nsresult ConvertToUnicode(const nsString aCharset,
|
||||
const char *inCString,
|
||||
nsString &outString);
|
||||
extern const char *msgCompHeaderInternalCharset(void);
|
||||
|
||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
||||
|
@ -226,17 +229,36 @@ nsComposeAppCore::ConstructAfterJavaScript(nsIWebShell *aWebShell)
|
|||
|
||||
if (mMsgCompFields && domDoc)
|
||||
{
|
||||
char *aString;
|
||||
mMsgCompFields->GetTo(&aString);
|
||||
nsString to = aString;
|
||||
mMsgCompFields->GetCc(&aString);
|
||||
nsString cc = aString;
|
||||
mMsgCompFields->GetBcc(&aString);
|
||||
nsString bcc = aString;
|
||||
mMsgCompFields->GetSubject(&aString);
|
||||
nsString subject = aString;
|
||||
mMsgCompFields->GetBody(&aString);
|
||||
nsString body = aString;
|
||||
nsString aCharset(msgCompHeaderInternalCharset());
|
||||
char *aString;
|
||||
nsString to, cc, bcc, subject, body;
|
||||
nsresult res;
|
||||
|
||||
mMsgCompFields->GetTo(&aString);
|
||||
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, to))) {
|
||||
to = aString;
|
||||
}
|
||||
mMsgCompFields->GetCc(&aString);
|
||||
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, cc))) {
|
||||
cc = aString;
|
||||
}
|
||||
mMsgCompFields->GetBcc(&aString);
|
||||
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, bcc))) {
|
||||
bcc = aString;
|
||||
}
|
||||
mMsgCompFields->GetSubject(&aString);
|
||||
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, subject))) {
|
||||
to = subject;
|
||||
}
|
||||
|
||||
// mail charset is used for the body instead of utf-8
|
||||
char *mail_charset;
|
||||
mMsgCompFields->GetCharacterSet(&mail_charset);
|
||||
aCharset.SetString(mail_charset);
|
||||
mMsgCompFields->GetBody(&aString);
|
||||
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, body))) {
|
||||
body = subject;
|
||||
}
|
||||
|
||||
SetWindowFields(domDoc, to, cc, bcc, subject, body);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче