[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    [Kde-pim] [patch] KMail: fox for text codecs + questions on
From:       Jarosław Staniek <js () iidea ! pl>
Date:       2008-03-14 8:35:12
Message-ID: 47DA38C0.40607 () iidea ! pl
[Download RAW message or body]

For review.
1. For creating emails use codec returned by KGlobal::locale()->encoding(), 
what on non-windows is equal to QTextCodec::codecForLocale() (see 
KLocalePrivate::initEncoding()).
On windows QTextCodec::codecForLocale() returns "System", so we're using 
GetLocaleInfo() to get the actual CP system's charset.

We'd map that to ISO soon (on any platform, I guess), preferably using a small 
array coming from GNU Mailutils' locale.c [1].

CC'd to core-devel: do you think we could put the ISO-mapping functionality in 
KCharsets? Useful for various converters when we want sane defaults instead of 
CP charsets.

1.1. Additional question:
 From the QTextCodec::codecForLocale() docs:
  ''On Windows, the codec will be based on a system locale. On Unix systems,
   starting with Qt 4.2, the codec will be using the iconv library. Note that
   in  both cases the codec's name will be "System".''
So did QTextCodec::codecForLocale() work for us on UNIX before my patch, since 
QTextCodec::codecForLocale()->name()=="System"?
I especially mean that this line wouldn't work as expected for >=Qt4.2:
  QByteArray(QTextCodec::codecForLocale()->name()).toLower() == "eucjp"

Moreover, we have to find all the uses of QTextCodec::codecForLocale()->name() 
in KDE, like the one in KNode::Settings::Settings(), and preferably fix them 
in a similar way as in KMail.


2. A fix for japanese codec on Windows and Mac (just switches from shift-jis 
to jis7 in addition to the previous behaviour so would not break things), see 
the comment added in the code.


[1] 
http://www.koders.com/c/fid63F33F4A9791A8C976B1D18A40A8A452DA0B296C.aspx?s=gnu+mailutils#L1

-- 
regards / pozdrawiam, Jaroslaw Staniek
  Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
  Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
  KDE Libraries for MS Windows (http://windows.kde.org)

["codec_win_and_japanese.patch" (text/plain)]

Index: kmail/kmkernel.cpp
===================================================================
--- kmail/kmkernel.cpp	(revision 785504)
+++ kmail/kmkernel.cpp	(working copy)
@@ -139,17 +139,25 @@
 
   new Kpgp::Module();
 
+  netCodec = QTextCodec::codecForName( KGlobal::locale()->encoding() );
+
   // In the case of Japan. Japanese locale name is "eucjp" but
   // The Japanese mail systems normally used "iso-2022-jp" of locale name.
   // We want to change locale name from eucjp to iso-2022-jp at KMail only.
-  if ( QByteArray(QTextCodec::codecForLocale()->name()).toLower() == "eucjp" )
+
+  // (Introduction to i18n, 6.6 Limit of Locale technology):
+  // EUC-JP is the de-facto standard for UNIX systems, ISO 2022-JP
+  // is the standard for Internet, and Shift-JIS is the encoding 
+  // for Windows and Macintosh.
+  if ( netCodec->name().toLower() == "eucjp" 
+#if defined Q_WS_WIN || defined Q_WS_MACX
+    || netCodec->name().toLower() == "shift-jis" ) // OK?
+#endif
   {
     netCodec = QTextCodec::codecForName("jis7");
     // QTextCodec *cdc = QTextCodec::codecForName("jis7");
     // QTextCodec::setCodecForLocale(cdc);
     // KGlobal::locale()->setEncoding(cdc->mibEnum());
-  } else {
-    netCodec = QTextCodec::codecForLocale();
   }
 
   connect( MailTransport::TransportManager::self(),


_______________________________________________
KDE PIM mailing list kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic