Hi,

I've got a few mails with UTF-7 encoding and decided to implement it.
Why after the following changes:

--- MessageView.cpp        19 Mar 2002 01:43:44 -0000        1.76
+++ MessageView.cpp        16 Apr 2002 01:44:11 -0000
@@ -82,6 +82,12 @@
    #include <wx/dcps.h> // for wxThePrintSetupData
 #endif
 
+#include "Mcclient.h"
+extern "C"
+{
+   #include "utf8.h"  // for utf8_text_utf7()
+}
+
 // ---------------------------------------------------------------------------- // 
options we use here
 // ----------------------------------------------------------------------------@@ 
-177,7 +183,7 @@
       {
          // conversion failed - use original text (and display incorrectly,
          // unfortunately)
-         wxLogDebug("conversion from UTF-8 to default encoding failed");
+         wxLogDebug("conversion from UTF-8(7) to default encoding failed");
       }
       else
       {
@@ -1176,9 +1182,32 @@
       wxString value = headerValues[n];
       if ( !EnsureAvailableTextEncoding(&encHeader, &value) )
       {
-         // special handling for the UTF-8 if it's not supported natively
+         // special handling for the UTF-7|8 if it's not supported natively
          if ( encHeader == wxFONTENCODING_UTF8 )
          {
+            encHeader = ConvertUnicodeToSystem(&value);
+         }
+         if ( encHeader == wxFONTENCODING_UTF7 )
+         {
+            //wxWindows does not support UTF-7 yet, so we first convert
+            //UTF-7 to UTF-8 using c-client function and then convert
+            //UTF-8 to current environment's encoding.
+
+            SIZEDTEXT *text7 = new SIZEDTEXT;
+            SIZEDTEXT *text8 = new SIZEDTEXT;
+            text7->data = (unsigned char *) value.c_str();
+            text7->size = value.Length();
+
+            void *tab = NULL;
+            utf8_text_utf7 ( text7, text8, tab );
+            value = "";
+            for ( unsigned long k = 0; k < text8->size; k++ )
+            {
+                value << wxChar(text8->data[k]);
+            }
+            free(text7);
+            free(text8);
+
             encHeader = ConvertUnicodeToSystem(&value);
          }
       }

it fails to compile with:

.src/classes/MessageView.cpp: In member function `void 
   MessageView::ShowPart(const MimePart*)':
.src/classes/MessageView.cpp:1764: parse error before `&&' token
.src/classes/MessageView.cpp: In member function `void 
   MessageView::ProcessPart(const MimePart*)':
.src/classes/MessageView.cpp:1842: parse error before `:' token
.src/classes/MessageView.cpp:1849: case label `MimeType::TEXT' not within a 
   switch statement
...
?

Regards,
Nerijus


_______________________________________________
Mahogany-Developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-developers

Reply via email to