зеркало из 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;
|
nsIUnicodeDecoder* decoder = nsnull;
|
||||||
PRUnichar *unichars;
|
PRUnichar *unichars;
|
||||||
PRInt32 unicharLength;
|
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
|
// get an unicode converter
|
||||||
res = ccm->GetUnicodeDecoder(&aCharset, &decoder);
|
res = ccm->GetUnicodeDecoder(&convCharset, &decoder);
|
||||||
if(NS_SUCCEEDED(res) && (nsnull != decoder)) {
|
if(NS_SUCCEEDED(res) && (nsnull != decoder)) {
|
||||||
PRInt32 srcLen = PL_strlen(inCString);
|
PRInt32 srcLen = PL_strlen(inCString);
|
||||||
res = decoder->Length(inCString, 0, srcLen, &unicharLength);
|
res = decoder->Length(inCString, 0, srcLen, &unicharLength);
|
||||||
|
|
|
@ -85,6 +85,9 @@ extern char * INTL_GetDefaultMailCharset(void);
|
||||||
extern nsresult ConvertFromUnicode(const nsString aCharset,
|
extern nsresult ConvertFromUnicode(const nsString aCharset,
|
||||||
const nsString inString,
|
const nsString inString,
|
||||||
char** outCString);
|
char** outCString);
|
||||||
|
extern nsresult ConvertToUnicode(const nsString aCharset,
|
||||||
|
const char *inCString,
|
||||||
|
nsString &outString);
|
||||||
extern const char *msgCompHeaderInternalCharset(void);
|
extern const char *msgCompHeaderInternalCharset(void);
|
||||||
|
|
||||||
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
|
// 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)
|
if (mMsgCompFields && domDoc)
|
||||||
{
|
{
|
||||||
|
nsString aCharset(msgCompHeaderInternalCharset());
|
||||||
char *aString;
|
char *aString;
|
||||||
|
nsString to, cc, bcc, subject, body;
|
||||||
|
nsresult res;
|
||||||
|
|
||||||
mMsgCompFields->GetTo(&aString);
|
mMsgCompFields->GetTo(&aString);
|
||||||
nsString to = aString;
|
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, to))) {
|
||||||
|
to = aString;
|
||||||
|
}
|
||||||
mMsgCompFields->GetCc(&aString);
|
mMsgCompFields->GetCc(&aString);
|
||||||
nsString cc = aString;
|
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, cc))) {
|
||||||
|
cc = aString;
|
||||||
|
}
|
||||||
mMsgCompFields->GetBcc(&aString);
|
mMsgCompFields->GetBcc(&aString);
|
||||||
nsString bcc = aString;
|
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, bcc))) {
|
||||||
|
bcc = aString;
|
||||||
|
}
|
||||||
mMsgCompFields->GetSubject(&aString);
|
mMsgCompFields->GetSubject(&aString);
|
||||||
nsString subject = 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);
|
mMsgCompFields->GetBody(&aString);
|
||||||
nsString body = aString;
|
if (NS_FAILED(res = ConvertToUnicode(aCharset, aString, body))) {
|
||||||
|
body = subject;
|
||||||
|
}
|
||||||
|
|
||||||
SetWindowFields(domDoc, to, cc, bcc, subject, body);
|
SetWindowFields(domDoc, to, cc, bcc, subject, body);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче