Changed to use unicode converter and related changes.

This commit is contained in:
nhotta%netscape.com 1999-04-06 21:46:15 +00:00
parent df45467ce6
commit 7305376997
2 changed files with 42 additions and 12 deletions

View File

@ -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);

View File

@ -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);
}