From 6837f5b69c695856cbb4a82937d33cb91440bb48 Mon Sep 17 00:00:00 2001 From: shatty Date: Thu, 11 Nov 2004 13:11:30 +0000 Subject: [PATCH] convert message body using textencoding, change default to latin 9 (iso-8859-15) instead of latin 1 (iso-8859-1) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9928 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/mail/MailComponent.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/kits/mail/MailComponent.cpp b/src/kits/mail/MailComponent.cpp index c5f2c22723..ba55ad5c70 100644 --- a/src/kits/mail/MailComponent.cpp +++ b/src/kits/mail/MailComponent.cpp @@ -18,6 +18,11 @@ class _EXPORT BTextMailComponent; #include #include +#include +#include + +using namespace BPrivate ; + struct CharsetConversionEntry { const char *charset; @@ -256,7 +261,7 @@ BMailComponent::SetToRFC822(BPositionIO *data, size_t /*length*/, bool /*parse_n status_t BMailComponent::RenderToRFC822(BPositionIO *render_to) { - int32 charset = B_ISO1_CONVERSION; + int32 charset = B_ISO15_CONVERSION; int8 encoding = quoted_printable; const char *key, *value; char *allocd; @@ -371,7 +376,7 @@ void BMailComponent::_ReservedComponent5() {} BTextMailComponent::BTextMailComponent(const char *text, uint32 defaultCharSet) : BMailComponent(defaultCharSet), encoding(quoted_printable), - charset(B_ISO1_CONVERSION), + charset(B_ISO15_CONVERSION), raw_data(NULL) { if (text != NULL) @@ -494,10 +499,15 @@ BTextMailComponent::ParseRaw() charset = _charSetForTextDecoding; if (charset == B_MAIL_NULL_CONVERSION && content_type.HasString("charset")) { - for (int32 i = 0; mail_charsets[i].charset != NULL; i++) { - if (strcasecmp(content_type.FindString("charset"), mail_charsets[i].charset) == 0) { - charset = mail_charsets[i].flavor; - break; + const char * charset_string = content_type.FindString("charset"); + if (strcasecmp(charset_string, "us-ascii") == 0) { + charset = B_MAIL_US_ASCII_CONVERSION; + } else if (strcasecmp(charset_string, "utf-8") == 0) { + charset = B_MAIL_UTF8_CONVERSION; + } else { + const BCharacterSet * cs = BCharacterSetRoster::FindCharacterSetByName(charset_string); + if (cs != NULL) { + charset = cs->GetConversionID(); } } } @@ -536,8 +546,8 @@ BTextMailComponent::ParseRaw() if (charset == B_MAIL_NULL_CONVERSION) { if (decoded.FindFirst ("\e$B") >= 0 || decoded.FindFirst ("\e$@") >= 0) charset = B_JIS_CONVERSION; - else // Just assume the usual Latin-1 character set. - charset = B_ISO1_CONVERSION; + else // Just assume the usual Latin-9 character set. + charset = B_ISO15_CONVERSION; } int32 state = 0;