Bug 1006498 - Import nsCharsetConverterManager into c-c. r=Neil, patch originally due to Henri Sivonen. CLOSED TREE.
authorJoshua Cranmer <Pidgeot18@gmail.com>
Mon, 12 May 2014 09:14:06 -0500
changeset 16187 e41e714750eb242b1a6022b346717076d91f0bb3
parent 16186 06bdc6dad628f6d107292696f69850990ce2415c
child 16188 ac9aa13e8d1cc67678d8267414b824ba704142dd
push id10119
push userPidgeot18@gmail.com
push dateMon, 12 May 2014 14:14:29 +0000
treeherdercomm-central@e41e714750eb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, patch
bugs1006498
Bug 1006498 - Import nsCharsetConverterManager into c-c. r=Neil, patch originally due to Henri Sivonen. CLOSED TREE.
mail/locales/en-US/chrome/messenger/charsetTitles.properties
mail/locales/jar.mn
mailnews/build/nsMailModule.cpp
mailnews/intl/Makefile.in
mailnews/intl/charsetData.properties
mailnews/intl/charsetalias.properties
mailnews/intl/jar.mn
mailnews/intl/moz.build
mailnews/intl/nsCharsetAlias.cpp
mailnews/intl/nsCharsetAlias.h
mailnews/intl/nsCharsetConverterManager.cpp
mailnews/intl/nsCharsetConverterManager.h
mailnews/intl/nsICharsetConverterManager.idl
suite/locales/en-US/chrome/mailnews/charsetTitles.properties
suite/locales/jar.mn
new file mode 100644
--- /dev/null
+++ b/mail/locales/en-US/chrome/messenger/charsetTitles.properties
@@ -0,0 +1,104 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+## Rule of this file:
+## 1. key should always be in lower case ascii so we can do case insensitive
+##    comparison in the code faster.
+
+## Format of this file:
+## charset_name.title = a_title  -  specifies the human readable title for 
+## this charset
+
+us-ascii.title    = English (US-ASCII)
+iso-8859-1.title    = Western (ISO-8859-1)
+iso-8859-2.title    = Central European (ISO-8859-2)
+iso-8859-3.title    = South European (ISO-8859-3)
+iso-8859-4.title    = Baltic (ISO-8859-4)
+iso-8859-9.title    = Turkish (ISO-8859-9)
+iso-8859-10.title   = Nordic (ISO-8859-10)
+iso-8859-13.title   = Baltic (ISO-8859-13)
+iso-8859-14.title   = Celtic (ISO-8859-14)
+iso-8859-15.title   = Western (ISO-8859-15)
+iso-8859-16.title   = Romanian (ISO-8859-16)
+windows-1250.title  = Central European (Windows-1250)
+windows-1252.title  = Western (Windows-1252)
+windows-1254.title  = Turkish (Windows-1254)
+windows-1257.title  = Baltic (Windows-1257)
+macintosh.title         = Western (MacRoman)
+x-mac-ce.title          = Central European (MacCE)
+x-mac-turkish.title     = Turkish (MacTurkish)
+x-mac-croatian.title    = Croatian (MacCroatian)
+x-mac-romanian.title    = Romanian (MacRomanian)
+x-mac-icelandic.title   = Icelandic (MacIcelandic)
+iso-2022-jp.title = Japanese (ISO-2022-JP)
+shift_jis.title = Japanese (Shift_JIS)
+euc-jp.title = Japanese (EUC-JP)
+big5.title = Chinese Traditional (Big5)
+big5-hkscs.title = Chinese Traditional (Big5-HKSCS)
+x-euc-tw.title = Chinese Traditional (EUC-TW)
+gb2312.title = Chinese Simplified (GB2312)
+hz-gb-2312.title = Chinese Simplified (HZ)
+gbk.title = Chinese Simplified (GBK)
+iso-2022-cn.title = Chinese Simplified (ISO-2022-CN)
+euc-kr.title = Korean (EUC-KR)
+x-johab.title = Korean (JOHAB)
+iso-2022-kr.title = Korean (ISO-2022-KR)
+utf-7.title = Unicode (UTF-7)
+utf-8.title = Unicode (UTF-8)
+utf-16.title = Unicode (UTF-16)
+utf-16le.title = Unicode (UTF-16LE)
+utf-16be.title = Unicode (UTF-16BE)
+iso-8859-5.title = Cyrillic (ISO-8859-5)
+iso-ir-111.title = Cyrillic (ISO-IR-111)
+windows-1251.title = Cyrillic (Windows-1251)
+x-mac-cyrillic.title = Cyrillic (MacCyrillic)
+x-mac-ukrainian.title = Cyrillic/Ukrainian (MacUkrainian)
+koi8-r.title = Cyrillic (KOI8-R)
+koi8-u.title = Cyrillic/Ukrainian (KOI8-U)
+iso-8859-7.title = Greek (ISO-8859-7)
+windows-1253.title = Greek (Windows-1253)
+x-mac-greek.title = Greek (MacGreek)
+windows-1258.title = Vietnamese (Windows-1258)
+x-viet-tcvn5712.title = Vietnamese (TCVN)
+viscii.title = Vietnamese (VISCII)
+x-viet-vps.title = Vietnamese (VPS)
+tis-620.title = Thai (TIS-620)
+iso-8859-11.title = Thai (ISO-8859-11)
+windows-874.title = Thai (Windows-874)
+ibm874.title = Thai (IBM-874)
+armscii-8.title = Armenian (ARMSCII-8)
+iso-8859-6.title = Arabic (ISO-8859-6)
+iso-8859-6-i.title = Arabic (ISO-8859-6-I)
+iso-8859-6-e.title = Arabic (ISO-8859-6-E)
+iso-8859-8.title = Hebrew Visual (ISO-8859-8)
+iso-8859-8-i.title = Hebrew (ISO-8859-8-I)
+iso-8859-8-e.title = Hebrew (ISO-8859-8-E)
+windows-1255.title = Hebrew (Windows-1255)
+windows-1256.title = Arabic (Windows-1256)
+x-user-defined.title = User Defined
+ibm866.title = Cyrillic/Russian (CP-866)
+ibm850.title = Western (IBM-850)
+ibm852.title = Central European (IBM-852)
+ibm855.title = Cyrillic (IBM-855)
+ibm857.title = Turkish (IBM-857)
+ibm862.title = Hebrew (IBM-862)
+gb18030.title = Chinese Simplified (GB18030)
+x-mac-arabic.title = Arabic (MacArabic)
+x-mac-farsi.title = Farsi (MacFarsi)
+x-mac-hebrew.title = Hebrew (MacHebrew)
+x-mac-devanagari.title = Hindi (MacDevanagari)
+x-mac-gujarati.title = Gujarati (MacGujarati)
+x-mac-gurmukhi.title = Gurmukhi (MacGurmukhi)
+
+
+chardet.off.title                           = (Off)
+chardet.universal_charset_detector.title    = Universal
+chardet.ja_parallel_state_machine.title     = Japanese
+chardet.ko_parallel_state_machine.title     = Korean
+chardet.zhtw_parallel_state_machine.title   = Traditional Chinese
+chardet.zhcn_parallel_state_machine.title   = Simplified Chinese
+chardet.zh_parallel_state_machine.title     = Chinese
+chardet.cjk_parallel_state_machine.title    = East Asian
+chardet.ruprob.title                        = Russian
+chardet.ukprob.title                        = Ukrainian
--- a/mail/locales/jar.mn
+++ b/mail/locales/jar.mn
@@ -14,16 +14,17 @@
   locale/@AB_CD@/messenger/aboutRights.properties                       (%chrome/messenger/aboutRights.properties)
   locale/@AB_CD@/messenger/aboutSupportMail.dtd                         (%chrome/messenger/aboutSupportMail.dtd)
   locale/@AB_CD@/messenger/aboutSupportMail.properties                  (%chrome/messenger/aboutSupportMail.properties)
   locale/@AB_CD@/messenger/telemetry.properties                         (%chrome/messenger/telemetry.properties)
   locale/@AB_CD@/messenger/accountCreation.dtd                          (%chrome/messenger/accountCreation.dtd)
   locale/@AB_CD@/messenger/accountCreation.properties                   (%chrome/messenger/accountCreation.properties)
   locale/@AB_CD@/messenger/accountCreationModel.properties              (%chrome/messenger/accountCreationModel.properties)
   locale/@AB_CD@/messenger/accountCreationUtil.properties               (%chrome/messenger/accountCreationUtil.properties)
+  locale/@AB_CD@/messenger/charsetTitles.properties                     (%chrome/messenger/charsetTitles.properties)
   locale/@AB_CD@/messenger/systemIntegrationDialog.dtd                  (%chrome/messenger/systemIntegrationDialog.dtd)  
   locale/@AB_CD@/messenger/virtualFolderProperties.dtd                  (%chrome/messenger/virtualFolderProperties.dtd)
   locale/@AB_CD@/messenger/virtualFolderListDialog.dtd                  (%chrome/messenger/virtualFolderListDialog.dtd)
   locale/@AB_CD@/messenger/multimessageview.properties                  (%chrome/messenger/multimessageview.properties)
   locale/@AB_CD@/messenger/multimessageview.dtd                         (%chrome/messenger/multimessageview.dtd)
   locale/@AB_CD@/messenger/mailOverlay.dtd                              (%chrome/messenger/mailOverlay.dtd)
   locale/@AB_CD@/messenger/messenger.dtd                                (%chrome/messenger/messenger.dtd)
   locale/@AB_CD@/messenger/viewZoomOverlay.dtd                          (%chrome/messenger/viewZoomOverlay.dtd)
--- a/mailnews/build/nsMailModule.cpp
+++ b/mailnews/build/nsMailModule.cpp
@@ -300,16 +300,18 @@
 #include "nsPgpMimeProxy.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // i18n includes
 ////////////////////////////////////////////////////////////////////////////////
 #include "nsEncoderDecoderUtils.h"
 #include "nsCommUConvCID.h"
 
+#include "nsCharsetConverterManager.h"
+
 #include "nsUTF7ToUnicode.h"
 #include "nsMUTF7ToUnicode.h"
 #include "nsUnicodeToUTF7.h"
 #include "nsUnicodeToMUTF7.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // mailnews base factories
 ////////////////////////////////////////////////////////////////////////////////
@@ -815,21 +817,25 @@ nsPgpMimeMimeContentTypeHandlerConstruct
 
   return inst->QueryInterface(aIID, aResult);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // i18n factories
 ////////////////////////////////////////////////////////////////////////////////
 
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetConverterManager)
+
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUTF7ToUnicode)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMUTF7ToUnicode)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToUTF7)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToMUTF7)
 
+NS_DEFINE_NAMED_CID(NS_ICHARSETCONVERTERMANAGER_CID);
+
 NS_DEFINE_NAMED_CID(NS_UTF7TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_MUTF7TOUNICODE_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOUTF7_CID);
 NS_DEFINE_NAMED_CID(NS_UNICODETOMUTF7_CID);
 
 const mozilla::Module::CIDEntry kMailNewsCIDs[] = {
   // MailNews Base Entries
   { &kNS_MESSENGERBOOTSTRAP_CID, false, NULL, nsMessengerBootstrapConstructor },
@@ -1025,16 +1031,17 @@ const mozilla::Module::CIDEntry kMailNew
   { &kNS_SMIMEJSJELPER_CID, false, NULL, nsSMimeJSHelperConstructor },
   { &kNS_SMIMEENCRYPTURISERVICE_CID, false, NULL, nsEncryptedSMIMEURIsServiceConstructor },
   // Vcard Entries
   { &kNS_VCARD_CONTENT_TYPE_HANDLER_CID, false, NULL, nsVCardMimeContentTypeHandlerConstructor},
   // PGP/MIME Entries
   { &kNS_PGPMIME_CONTENT_TYPE_HANDLER_CID, false, NULL, nsPgpMimeMimeContentTypeHandlerConstructor },
   { &kNS_PGPMIMEPROXY_CID, false, NULL, nsPgpMimeProxyConstructor },
   // i18n Entries
+  { &kNS_ICHARSETCONVERTERMANAGER_CID, false, nullptr, nsCharsetConverterManagerConstructor },
   { &kNS_UTF7TOUNICODE_CID, false, nullptr, nsUTF7ToUnicodeConstructor },
   { &kNS_MUTF7TOUNICODE_CID, false, nullptr, nsMUTF7ToUnicodeConstructor },
   { &kNS_UNICODETOUTF7_CID, false, nullptr, nsUnicodeToUTF7Constructor },
   { &kNS_UNICODETOMUTF7_CID, false, nullptr, nsUnicodeToMUTF7Constructor },
   // Tokenizer Entries
   { NULL }
 };
 
@@ -1260,16 +1267,17 @@ const mozilla::Module::ContractIDEntry k
   { NS_SMIMEJSHELPER_CONTRACTID, &kNS_SMIMEJSJELPER_CID },
   { NS_SMIMEENCRYPTURISERVICE_CONTRACTID, &kNS_SMIMEENCRYPTURISERVICE_CID },
   // Vcard Entries
   { "@mozilla.org/mimecth;1?type=text/x-vcard", &kNS_VCARD_CONTENT_TYPE_HANDLER_CID },
   // PGP/MIME Entries
   { "@mozilla.org/mimecth;1?type=multipart/encrypted", &kNS_PGPMIME_CONTENT_TYPE_HANDLER_CID },
   { NS_PGPMIMEPROXY_CONTRACTID, &kNS_PGPMIMEPROXY_CID },
   // i18n Entries
+  { NS_CHARSETCONVERTERMANAGER_CONTRACTID, &kNS_ICHARSETCONVERTERMANAGER_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "UTF-7", &kNS_UTF7TOUNICODE_CID },
   { NS_UNICODEDECODER_CONTRACTID_BASE "x-imap4-modified-utf7", &kNS_MUTF7TOUNICODE_CID },
   { NS_UNICODEENCODER_CONTRACTID_BASE "UTF-7", &kNS_UNICODETOUTF7_CID },
   { NS_UNICODEENCODER_CONTRACTID_BASE "x-imap4-modified-utf7", &kNS_UNICODETOMUTF7_CID },
   // Tokenizer Entries
   { NULL }
 };
 
@@ -1295,16 +1303,18 @@ static const mozilla::Module::CategoryEn
   { "mime-emitter", NS_XML_MIME_EMITTER_CONTRACTID, NS_XML_MIME_EMITTER_CONTRACTID },
   { "mime-emitter", NS_PLAIN_MIME_EMITTER_CONTRACTID, NS_PLAIN_MIME_EMITTER_CONTRACTID },
   { "mime-emitter", NS_RAW_MIME_EMITTER_CONTRACTID, NS_RAW_MIME_EMITTER_CONTRACTID },
   // News Entries
   { "command-line-handler", "m-news", NS_NEWSSTARTUPHANDLER_CONTRACTID },
   // Mail View Entries
   // mdn Entries
   // i18n Entries
+  { NS_TITLE_BUNDLE_CATEGORY, "chrome://messenger/locale/charsetTitles.properties", "" },
+  { NS_DATA_BUNDLE_CATEGORY, "resource://gre-resources/charsetData.properties", "" },
   NS_UCONV_REG_UNREG("UTF-7", NS_UTF7TOUNICODE_CID, NS_UNICODETOUTF7_CID)
   NS_UCONV_REG_UNREG("x-imap4-modified-utf7", NS_MUTF7TOUNICODE_CID, NS_UNICODETOMUTF7_CID)
   // Tokenizer Entries
   { NULL }
 };
 
 static void
 msgMailNewsModuleDtor()
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/Makefile.in
@@ -0,0 +1,12 @@
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+include $(topsrcdir)/config/rules.mk
+
+PROPS2ARRAYS := $(MOZILLA_DIR)/intl/locale/src/props2arrays.py
+charsetalias.properties.h: $(PROPS2ARRAYS) charsetalias.properties
+	$(PYTHON) $^ $@
+
+export:: charsetalias.properties.h
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/charsetData.properties
@@ -0,0 +1,177 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+## Rule of this file:
+## 1. key should always be in lower case ascii so we can do case insensitive
+##    comparison in the code faster.
+
+## Format of this file:
+##
+## charset_name.notForOutgoing = anything  -  specifies that this charset is 
+## not to be used for exporting files ('SaveAsCharset' in composer)
+##
+## charset_name.isInternal = anything - specifies that this charset should
+## not be exposed to web content because of the vulnerability to XSS attacks
+## or some other reasons
+##
+## charset_name.LangGroup = 
+##
+## charset_name.isMultibyte = multi byte charsets
+
+x-mac-arabic.isInternal                 = true
+x-mac-farsi.isInternal                  = true
+x-mac-hebrew.isInternal                 = true
+x-imap4-modified-utf7.isInternal        = true
+utf-7.isInternal                        = true
+t.61-8bit.isInternal                    = true
+ibm864.isInternal                       = true
+replacement.isInternal                  = true
+
+t.61-8bit.notForOutgoing                = true
+utf-7.notForOutgoing                    = true
+x-imap4-modified-utf7.notForOutgoing    = true
+us-ascii.notForOutgoing                 = true
+iso-8859-6-e.notForOutgoing             = true
+iso-8859-6-i.notForOutgoing             = true
+ibm864.notForOutgoing                   = true
+ibm869.notForOutgoing                   = true
+ibm1125.notForOutgoing                  = true
+ibm1131.notForOutgoing                  = true
+iso-8859-8-e.notForOutgoing             = true
+iso-8859-8.notForOutgoing               = true
+iso-2022-kr.notForOutgoing              = true
+x-johab.notForOutgoing                  = true
+replacement.notForOutgoing              = true
+
+# XXX : there are some entries only necessary for Gtk/Xlib builds
+# to map  XLFD registry-encoding pairs to langGroups. they can be
+# removed once bug 215537 is fixed.
+
+# XXX : todo: move to something based on BCP 47 (RFC 5646);
+# these should primarily specify script (and sometimes region),
+# but NOT language.
+# See also https://bugzilla.mozilla.org/show_bug.cgi?id=756022
+# e.g. x-western      -> *-Latn-155 (Western Europe)
+#      x-central-euro -> *-Latn-151 (Eastern Europe)
+#      x-baltic       -> *-Latn-154 (Northern Europe)
+#      x-cyrillic     -> *-Cyrl
+#      zh-TW          -> *-Hant-TW
+#      zh-HK          -> *-Hant-HK
+#      zh-CN          -> *-Hans
+#      ja             -> *-Jpan
+#      ko             -> *-Hang
+#      tr             -> *-Latn-TR
+#      he             -> *-Hebr
+#      ar             -> *-Arab
+# etc
+
+armscii-8.LangGroup                = x-armn
+big5.LangGroup                     = zh-TW
+x-x-big5.LangGroup                 = zh-TW
+big5-hkscs.LangGroup               = zh-HK
+euc-jp.LangGroup                   = ja
+euc-kr.LangGroup                   = ko
+gb2312.LangGroup                   = zh-CN
+gb18030.LangGroup                  = zh-CN
+gb18030.2000-0.LangGroup           = zh-CN
+gb18030.2000-1.LangGroup           = zh-CN
+hkscs-1.LangGroup                  = zh-HK
+hz-gb-2312.LangGroup               = zh-CN
+ibm850.LangGroup                   = x-western
+ibm852.LangGroup                   = x-central-euro
+ibm855.LangGroup                   = x-cyrillic
+ibm857.LangGroup                   = tr
+ibm862.LangGroup                   = he
+ibm864.LangGroup                   = ar
+ibm866.LangGroup                   = x-cyrillic
+ibm869.LangGroup                   = el
+ibm1125.LangGroup                  = x-cyrillic
+ibm1131.LangGroup                  = x-cyrillic
+iso-2022-cn.LangGroup              = zh-CN
+iso-2022-jp.LangGroup              = ja
+iso-2022-kr.LangGroup              = ko
+iso-8859-1.LangGroup               = x-western
+iso-8859-10.LangGroup              = x-western
+iso-8859-14.LangGroup              = x-western
+iso-8859-15.LangGroup              = x-western
+iso-8859-2.LangGroup               = x-central-euro
+iso-8859-16.LangGroup              = x-central-euro
+iso-8859-3.LangGroup               = x-western
+iso-8859-4.LangGroup               = x-baltic
+iso-8859-13.LangGroup              = x-baltic
+iso-8859-5.LangGroup               = x-cyrillic
+iso-8859-6.LangGroup               = ar
+iso-8859-6-e.LangGroup             = ar
+iso-8859-6-i.LangGroup             = ar
+iso-8859-7.LangGroup               = el
+iso-8859-8.LangGroup               = he
+iso-8859-8-e.LangGroup             = he
+iso-8859-8-i.LangGroup             = he
+iso-8859-9.LangGroup               = tr
+jis_0208-1983.LangGroup            = ja
+koi8-r.LangGroup                   = x-cyrillic
+koi8-u.LangGroup                   = x-cyrillic
+iso-ir-111.LangGroup               = x-cyrillic
+shift_jis.LangGroup                = ja
+tis-620.LangGroup                  = th
+tis620-2.LangGroup                 = th
+windows-874.LangGroup              = th
+iso-8859-11.LangGroup              = th
+us-ascii.LangGroup                 = x-western
+t.61-8bit.LangGroup                = x-western
+utf-8.LangGroup                    = x-unicode
+utf-16.LangGroup                   = x-unicode
+utf-16be.LangGroup                 = x-unicode
+utf-16le.LangGroup                 = x-unicode
+utf-7.LangGroup                    = x-unicode
+x-imap4-modified-utf7.LangGroup    = x-unicode
+replacement.LangGroup              = x-unicode
+viscii.LangGroup                   = x-western
+x-viet-tcvn5712.LangGroup          = x-western
+x-viet-vps.LangGroup               = x-western
+windows-1250.LangGroup             = x-central-euro
+windows-1251.LangGroup             = x-cyrillic
+windows-1252.LangGroup             = x-western
+windows-1253.LangGroup             = el
+windows-1254.LangGroup             = tr
+windows-1255.LangGroup             = he
+windows-1256.LangGroup             = ar
+windows-1257.LangGroup             = x-baltic
+windows-1258.LangGroup             = x-western
+x-euc-tw.LangGroup                 = zh-TW
+gbk.LangGroup                      = zh-CN
+gb_2312-80.LangGroup               = zh-CN
+x-mac-ce.LangGroup                 = x-central-euro
+x-mac-croatian.LangGroup           = x-central-euro
+x-mac-cyrillic.LangGroup           = x-cyrillic
+x-mac-devanagari.LangGroup         = x-devanagari
+x-mac-farsi.LangGroup              = ar
+x-mac-greek.LangGroup              = el
+x-mac-gujarati.LangGroup           = x-gujr
+x-mac-gurmukhi.LangGroup           = x-guru
+x-mac-icelandic.LangGroup          = x-western
+macintosh.LangGroup                = x-western
+x-mac-turkish.LangGroup            = tr
+x-mac-ukrainian.LangGroup          = x-cyrillic
+x-mac-romanian.LangGroup           = x-central-euro
+x-user-defined.LangGroup           = x-unicode
+ks_c_5601-1987.LangGroup           = ko
+x-johab.LangGroup                  = ko
+x-mac-hebrew.LangGroup             = he
+x-mac-arabic.LangGroup             = ar
+
+iso-2022-jp.isMultibyte     = true
+shift_jis.isMultibyte       = true
+euc-jp.isMultibyte          = true
+big5.isMultibyte            = true
+big5-hkscs.isMultibyte      = true
+x-euc-tw.isMultibyte        = true
+gb2312.isMultibyte          = true
+hz-gb-2312.isMultibyte      = true
+iso-2022-kr.isMultibyte     = true
+euc-kr.isMultibyte          = true
+x-johab.isMultibyte         = true
+utf-7.isMultibyte           = true
+utf-8.isMultibyte           = true
+replacement.isMultibyte     = true
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/charsetalias.properties
@@ -0,0 +1,460 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Original Code has been modified by IBM Corporation.
+# Modifications made by IBM described herein are
+# Copyright (c) International Business Machines
+# Corporation, 1999
+#
+# Modifications to Mozilla code or documentation
+# identified per MPL Section 3.3
+#
+# Date         Modified by     Description of modification
+# 12/09/1999   IBM Corp.       Support for IBM codepages - 850,852,855,857,862,864
+#
+# Rule of this file:
+# 1. key should always be in lower case ascii so we can do case insensitive
+#    comparison in the code faster.
+# 2. value should be the one used in unicode converter
+#
+# 3. If the charset is not used for document charset, but font charset
+#    (e.g. XLFD charset- such as JIS x0201, JIS x0208), don't put here
+#
+
+ascii=us-ascii
+us-ascii=us-ascii
+ansi_x3.4-1968=us-ascii
+646=us-ascii
+iso-8859-1=ISO-8859-1
+iso-8859-2=ISO-8859-2
+iso-8859-3=ISO-8859-3
+iso-8859-4=ISO-8859-4
+iso-8859-5=ISO-8859-5
+iso-8859-6=ISO-8859-6
+iso-8859-6-i=ISO-8859-6-I
+iso-8859-6-e=ISO-8859-6-E
+iso-8859-7=ISO-8859-7
+iso-8859-8=ISO-8859-8
+iso-8859-8-i=ISO-8859-8-I
+iso-8859-8-e=ISO-8859-8-E
+iso-8859-9=ISO-8859-9
+iso-8859-10=ISO-8859-10
+iso-8859-11=ISO-8859-11
+iso-8859-13=ISO-8859-13
+iso-8859-14=ISO-8859-14
+iso-8859-15=ISO-8859-15
+iso-8859-16=ISO-8859-16
+iso-ir-111=ISO-IR-111
+iso-2022-cn=ISO-2022-CN
+iso-2022-cn-ext=ISO-2022-CN
+iso-2022-kr=ISO-2022-KR
+iso-2022-jp=ISO-2022-JP
+utf-16be=UTF-16BE
+utf-16le=UTF-16LE
+utf-16=UTF-16
+windows-1250=windows-1250
+windows-1251=windows-1251
+windows-1252=windows-1252
+windows-1253=windows-1253
+windows-1254=windows-1254
+windows-1255=windows-1255
+windows-1256=windows-1256
+windows-1257=windows-1257
+windows-1258=windows-1258
+ibm866=IBM866
+ibm850=IBM850
+ibm852=IBM852
+ibm855=IBM855
+ibm857=IBM857
+ibm862=IBM862
+ibm864=IBM864
+utf-8=UTF-8
+utf-7=UTF-7
+shift_jis=Shift_JIS
+big5=Big5
+euc-jp=EUC-JP
+euc-kr=EUC-KR
+gb2312=GB2312
+gb18030=gb18030
+viscii=VISCII
+koi8-r=KOI8-R
+koi8_r=KOI8-R
+cskoi8r=KOI8-R
+koi=KOI8-R
+koi8=KOI8-R
+koi8-u=KOI8-U
+tis-620=TIS-620
+t.61-8bit=T.61-8bit
+hz-gb-2312=HZ-GB-2312
+big5-hkscs=Big5-HKSCS
+gbk=gbk
+cns11643=x-euc-tw
+#
+# Netscape private ...
+#
+x-imap4-modified-utf7=x-imap4-modified-utf7
+x-euc-tw=x-euc-tw
+x-mac-ce=x-mac-ce
+x-mac-turkish=x-mac-turkish
+x-mac-greek=x-mac-greek
+x-mac-icelandic=x-mac-icelandic
+x-mac-croatian=x-mac-croatian
+x-mac-romanian=x-mac-romanian
+x-mac-cyrillic=x-mac-cyrillic
+x-mac-ukrainian=x-mac-cyrillic
+x-mac-hebrew=x-mac-hebrew
+x-mac-arabic=x-mac-arabic
+x-mac-farsi=x-mac-farsi
+x-mac-devanagari=x-mac-devanagari
+x-mac-gujarati=x-mac-gujarati
+x-mac-gurmukhi=x-mac-gurmukhi
+armscii-8=armscii-8
+x-viet-tcvn5712=x-viet-tcvn5712
+x-viet-vps=x-viet-vps
+iso-10646-ucs-2=UTF-16BE
+x-iso-10646-ucs-2-be=UTF-16BE
+x-iso-10646-ucs-2-le=UTF-16LE
+x-user-defined=x-user-defined
+x-johab=x-johab
+#
+# Aliases for ISO-8859-1
+#
+latin1=ISO-8859-1
+iso_8859-1=ISO-8859-1
+iso8859-1=ISO-8859-1
+iso8859-2=ISO-8859-2
+iso8859-3=ISO-8859-3
+iso8859-4=ISO-8859-4
+iso8859-5=ISO-8859-5
+iso8859-6=ISO-8859-6
+iso8859-7=ISO-8859-7
+iso8859-8=ISO-8859-8
+iso8859-9=ISO-8859-9
+iso8859-10=ISO-8859-10
+iso8859-11=ISO-8859-11
+iso8859-13=ISO-8859-13
+iso8859-14=ISO-8859-14
+iso8859-15=ISO-8859-15
+iso_8859-1:1987=ISO-8859-1
+iso-ir-100=ISO-8859-1
+l1=ISO-8859-1
+ibm819=ISO-8859-1
+cp819=ISO-8859-1
+csisolatin1=ISO-8859-1
+#
+# Aliases for ISO-8859-2
+#
+latin2=ISO-8859-2
+iso_8859-2=ISO-8859-2
+iso_8859-2:1987=ISO-8859-2
+iso-ir-101=ISO-8859-2
+l2=ISO-8859-2
+csisolatin2=ISO-8859-2
+#
+# Aliases for ISO-8859-3
+#
+latin3=ISO-8859-3
+iso_8859-3=ISO-8859-3
+iso_8859-3:1988=ISO-8859-3
+iso-ir-109=ISO-8859-3
+l3=ISO-8859-3
+csisolatin3=ISO-8859-3
+#
+# Aliases for ISO-8859-4
+#
+latin4=ISO-8859-4
+iso_8859-4=ISO-8859-4
+iso_8859-4:1988=ISO-8859-4
+iso-ir-110=ISO-8859-4
+l4=ISO-8859-4
+csisolatin4=ISO-8859-4
+#
+# Aliases for ISO-8859-5
+#
+cyrillic=ISO-8859-5
+iso_8859-5=ISO-8859-5
+iso_8859-5:1988=ISO-8859-5
+iso-ir-144=ISO-8859-5
+csisolatincyrillic=ISO-8859-5
+#
+# Aliases for ISO-8859-6
+#
+arabic=ISO-8859-6
+iso_8859-6=ISO-8859-6
+iso_8859-6:1987=ISO-8859-6
+iso-ir-127=ISO-8859-6
+ecma-114=ISO-8859-6
+asmo-708=ISO-8859-6
+csisolatinarabic=ISO-8859-6
+#
+# Aliases for ISO-8859-6-I
+#
+csiso88596i=ISO-8859-6-I
+#
+# Aliases for ISO-8859-6-E
+#
+csiso88596e=ISO-8859-6-E
+#
+# Aliases for ISO-8859-7
+#
+greek=ISO-8859-7
+greek8=ISO-8859-7
+sun_eu_greek=ISO-8859-7
+iso_8859-7=ISO-8859-7
+iso_8859-7:1987=ISO-8859-7
+iso-ir-126=ISO-8859-7
+elot_928=ISO-8859-7
+ecma-118=ISO-8859-7
+csisolatingreek=ISO-8859-7
+#
+# Aliases for ISO-8859-8
+#
+hebrew=ISO-8859-8
+iso_8859-8=ISO-8859-8
+visual=ISO-8859-8
+iso_8859-8:1988=ISO-8859-8
+iso-ir-138=ISO-8859-8
+csisolatinhebrew=ISO-8859-8
+#
+# Aliases for ISO-8859-8-I
+#
+csiso88598i=ISO-8859-8-I
+iso-8859-8i=ISO-8859-8-I
+logical=ISO-8859-8-I
+#
+# Aliases for ISO-8859-8-E
+#
+csiso88598e=ISO-8859-8-E
+#
+# Aliases for ISO-8859-9
+#
+latin5=ISO-8859-9
+iso_8859-9=ISO-8859-9
+iso_8859-9:1989=ISO-8859-9
+iso-ir-148=ISO-8859-9
+l5=ISO-8859-9
+csisolatin5=ISO-8859-9
+#
+# Aliases for UTF-8
+#
+unicode-1-1-utf-8=UTF-8
+# nl_langinfo(CODESET) in HP/UX returns 'utf8' under UTF-8 locales
+utf8=UTF-8
+#
+# Aliases for Shift_JIS
+#
+x-sjis=Shift_JIS
+shift-jis=Shift_JIS
+ms_kanji=Shift_JIS
+csshiftjis=Shift_JIS
+windows-31j=Shift_JIS
+cp932=Shift_JIS
+sjis=Shift_JIS
+#
+# Aliases for EUC_JP
+#
+cseucpkdfmtjapanese=EUC-JP
+x-euc-jp=EUC-JP
+#
+# Aliases for ISO-2022-JP
+#
+csiso2022jp=ISO-2022-JP
+# The following are really not aliases ISO-2022-JP, but sharing the same decoder
+iso-2022-jp-2=ISO-2022-JP
+csiso2022jp2=ISO-2022-JP
+#
+# Aliases for Big5
+#
+csbig5=Big5
+cn-big5=Big5
+# x-x-big5 is not really a alias for Big5, add it only for MS FrontPage
+x-x-big5=Big5
+# Sun Solaris
+zh_tw-big5=Big5
+#
+# Aliases for EUC-KR
+#
+cseuckr=EUC-KR
+ks_c_5601-1987=EUC-KR
+iso-ir-149=EUC-KR
+ks_c_5601-1989=EUC-KR
+ksc_5601=EUC-KR
+ksc5601=EUC-KR
+korean=EUC-KR
+csksc56011987=EUC-KR
+5601=EUC-KR
+windows-949=EUC-KR
+#
+# Aliases for GB2312
+#
+# The following are really not aliases GB2312, add them only for MS FrontPage
+gb_2312-80=GB2312
+iso-ir-58=GB2312
+chinese=GB2312
+csiso58gb231280=GB2312
+csgb2312=GB2312
+zh_cn.euc=GB2312
+# Sun Solaris
+gb_2312=GB2312
+#
+# Aliases for windows-125x 
+#
+x-cp1250=windows-1250
+x-cp1251=windows-1251
+x-cp1252=windows-1252
+x-cp1253=windows-1253
+x-cp1254=windows-1254
+x-cp1255=windows-1255
+x-cp1256=windows-1256
+x-cp1257=windows-1257
+x-cp1258=windows-1258
+#
+# Aliases for windows-874 
+#
+windows-874=windows-874
+ibm874=windows-874
+dos-874=windows-874
+#
+# Aliases for macintosh
+#
+macintosh=macintosh
+x-mac-roman=macintosh
+mac=macintosh
+csmacintosh=macintosh
+#
+# Aliases for IBM866
+#
+cp866=IBM866
+cp-866=IBM866
+866=IBM866
+csibm866=IBM866
+#
+# Aliases for IBM850
+#
+cp850=IBM850
+850=IBM850
+csibm850=IBM850
+#
+# Aliases for IBM852
+#
+cp852=IBM852
+852=IBM852
+csibm852=IBM852
+#
+# Aliases for IBM855
+#
+cp855=IBM855
+855=IBM855
+csibm855=IBM855
+#
+# Aliases for IBM857
+#
+cp857=IBM857
+857=IBM857
+csibm857=IBM857
+#
+# Aliases for IBM862
+#
+cp862=IBM862
+862=IBM862
+csibm862=IBM862
+#
+# Aliases for IBM864
+#
+cp864=IBM864
+864=IBM864
+csibm864=IBM864
+ibm-864=IBM864
+#
+# Aliases for T.61-8bit
+#
+t.61=T.61-8bit
+iso-ir-103=T.61-8bit
+csiso103t618bit=T.61-8bit
+#
+# Aliases for UTF-7
+#
+x-unicode-2-0-utf-7=UTF-7
+unicode-2-0-utf-7=UTF-7
+unicode-1-1-utf-7=UTF-7
+csunicode11utf7=UTF-7
+#
+# Aliases for ISO-10646-UCS-2
+#
+csunicode=UTF-16BE
+csunicode11=UTF-16BE
+iso-10646-ucs-basic=UTF-16BE
+csunicodeascii=UTF-16BE
+iso-10646-unicode-latin1=UTF-16BE
+csunicodelatin1=UTF-16BE
+iso-10646=UTF-16BE
+iso-10646-j-1=UTF-16BE
+#
+# Aliases for ISO-8859-10
+#
+latin6=ISO-8859-10
+iso-ir-157=ISO-8859-10
+l6=ISO-8859-10
+# Currently .properties cannot handle : in key
+#iso_8859-10:1992=ISO-8859-10
+csisolatin6=ISO-8859-10
+#
+# Aliases for ISO-8859-15
+#
+iso_8859-15=ISO-8859-15
+csisolatin9=ISO-8859-15
+l9=ISO-8859-15
+#
+# Aliases for ISO-IR-111
+#
+ecma-cyrillic=ISO-IR-111
+csiso111ecmacyrillic=ISO-IR-111
+#
+# Aliases for ISO-2022-KR
+#
+csiso2022kr=ISO-2022-KR
+#
+# Aliases for VISCII
+#
+csviscii=VISCII
+#
+# Aliases for x-euc-tw
+#
+zh_tw-euc=x-euc-tw
+#
+# Following names appears in unix nl_langinfo(CODESET)
+# They can be compiled as platform specific if necessary
+# DONT put things here if it does not look generic enough (like hp15CN)
+#
+iso88591=ISO-8859-1
+iso88592=ISO-8859-2
+iso88593=ISO-8859-3
+iso88594=ISO-8859-4
+iso88595=ISO-8859-5
+iso88596=ISO-8859-6
+iso88597=ISO-8859-7
+iso88598=ISO-8859-8
+iso88599=ISO-8859-9
+iso885910=ISO-8859-10
+iso885911=ISO-8859-11
+iso885912=ISO-8859-12
+iso885913=ISO-8859-13
+iso885914=ISO-8859-14
+iso885915=ISO-8859-15
+#
+tis620=TIS-620
+#
+cp1250=windows-1250
+cp1251=windows-1251
+cp1252=windows-1252
+cp1253=windows-1253
+cp1254=windows-1254
+cp1255=windows-1255
+cp1256=windows-1256
+cp1257=windows-1257
+cp1258=windows-1258
+
+x-gbk=gbk
+windows-936=gbk
+ansi-1251=windows-1251
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/jar.mn
@@ -0,0 +1,6 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+toolkit.jar:
+    res/charsetData.properties                         (charsetData.properties)
--- a/mailnews/intl/moz.build
+++ b/mailnews/intl/moz.build
@@ -1,19 +1,33 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+XPIDL_SOURCES += [
+    'nsICharsetConverterManager.idl',
+]
+
 UNIFIED_SOURCES += [
+    'nsCharsetAlias.cpp',
+    'nsCharsetConverterManager.cpp',
     'nsMUTF7ToUnicode.cpp',
     'nsUnicodeToMUTF7.cpp',
     'nsUnicodeToUTF7.cpp',
     'nsUTF7ToUnicode.cpp',
 ]
 
+XPIDL_MODULE = 'commuconv'
+
+LOCAL_INCLUDES += [
+    '/mozilla/intl/locale/src',
+]
+
 MSVC_ENABLE_PGO = True
 
 FINAL_LIBRARY = 'mail'
 
 # Tests need more attention before they can be enabled.
 TEST_DIRS += ['test']
+
+JAR_MANIFESTS += ['jar.mn']
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/nsCharsetAlias.cpp
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/ArrayUtils.h"
+
+#include "nsCharsetAlias.h"
+
+// for NS_ERROR_UCONV_NOCONV
+#include "nsCharsetConverterManager.h"
+
+#include "nsUConvPropertySearch.h"
+
+using namespace mozilla;
+
+// 
+static const char* kAliases[][3] = {
+#include "charsetalias.properties.h"
+};
+
+//--------------------------------------------------------------
+// static
+nsresult
+nsCharsetAlias::GetPreferredInternal(const nsACString& aAlias,
+                                     nsACString& oResult)
+{
+   nsAutoCString key(aAlias);
+   ToLowerCase(key);
+
+   return nsUConvPropertySearch::SearchPropertyValue(kAliases,
+      ArrayLength(kAliases), key, oResult);
+}
+
+//--------------------------------------------------------------
+// static
+nsresult
+nsCharsetAlias::GetPreferred(const nsACString& aAlias,
+                             nsACString& oResult)
+{
+   if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
+
+   nsresult res = GetPreferredInternal(aAlias, oResult);
+   if (NS_FAILED(res))
+      return res;
+
+   if (nsCharsetConverterManager::IsInternal(oResult))
+      return NS_ERROR_UCONV_NOCONV;
+
+   return res;
+}
+
+//--------------------------------------------------------------
+// static
+nsresult
+nsCharsetAlias::Equals(const nsACString& aCharset1,
+                       const nsACString& aCharset2, bool* oResult)
+{
+   nsresult res = NS_OK;
+
+   if(aCharset1.Equals(aCharset2, nsCaseInsensitiveCStringComparator())) {
+      *oResult = true;
+      return res;
+   }
+
+   if(aCharset1.IsEmpty() || aCharset2.IsEmpty()) {
+      *oResult = false;
+      return res;
+   }
+
+   *oResult = false;
+   nsAutoCString name1;
+   res = GetPreferredInternal(aCharset1, name1);
+   if (NS_FAILED(res))
+     return res;
+
+   nsAutoCString name2;
+   res = GetPreferredInternal(aCharset2, name2);
+   if (NS_FAILED(res))
+     return res;
+
+   *oResult = name1.Equals(name2);
+   return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/nsCharsetAlias.h
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nsCharsetAlias_h___
+#define nsCharsetAlias_h___
+
+#include "nscore.h"
+#include "nsString.h"
+
+class nsCharsetConverterManager;
+class nsScriptableUnicodeConverter;
+
+class nsCharsetAlias
+{
+   friend class nsCharsetConverterManager;
+   friend class nsScriptableUnicodeConverter;
+   static nsresult GetPreferredInternal(const nsACString& aAlias, nsACString& aResult);
+public:
+   static nsresult GetPreferred(const nsACString& aAlias, nsACString& aResult);
+   static nsresult Equals(const nsACString& aCharset1, const nsACString& aCharset2, bool* aResult);
+};
+
+#endif /* nsCharsetAlias_h___ */
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/nsCharsetConverterManager.cpp
@@ -0,0 +1,356 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsCOMPtr.h"
+#include "nsString.h"
+#include "nsUnicharUtils.h"
+#include "nsCharsetAlias.h"
+#include "nsICategoryManager.h"
+#include "nsICharsetConverterManager.h"
+#include "nsEncoderDecoderUtils.h"
+#include "nsIStringBundle.h"
+#include "nsTArray.h"
+#include "nsStringEnumerator.h"
+#include "mozilla/Services.h"
+
+#include "nsComponentManagerUtils.h"
+#include "nsISupportsPrimitives.h"
+#include "nsServiceManagerUtils.h"
+
+// just for CONTRACTIDs
+#include "nsCharsetConverterManager.h"
+
+static nsIStringBundle * sDataBundle;
+static nsIStringBundle * sTitleBundle;
+
+// Class nsCharsetConverterManager [implementation]
+
+NS_IMPL_ISUPPORTS(nsCharsetConverterManager, nsICharsetConverterManager)
+
+nsCharsetConverterManager::nsCharsetConverterManager() 
+{
+}
+
+nsCharsetConverterManager::~nsCharsetConverterManager() 
+{
+}
+
+//static
+void nsCharsetConverterManager::Shutdown()
+{
+  NS_IF_RELEASE(sDataBundle);
+  NS_IF_RELEASE(sTitleBundle);
+}
+
+static
+nsresult LoadExtensibleBundle(const char* aCategory, 
+                              nsIStringBundle ** aResult)
+{
+  nsCOMPtr<nsIStringBundleService> sbServ =
+    mozilla::services::GetStringBundleService();
+  if (!sbServ)
+    return NS_ERROR_FAILURE;
+
+  return sbServ->CreateExtensibleBundle(aCategory, aResult);
+}
+
+static
+nsresult GetBundleValue(nsIStringBundle * aBundle, 
+                        const char * aName, 
+                        const nsAFlatString& aProp, 
+                        char16_t ** aResult)
+{
+  nsAutoString key; 
+
+  key.AssignWithConversion(aName);
+  ToLowerCase(key); // we lowercase the main comparison key
+  key.Append(aProp);
+
+  return aBundle->GetStringFromName(key.get(), aResult);
+}
+
+static
+nsresult GetBundleValue(nsIStringBundle * aBundle, 
+                        const char * aName, 
+                        const nsAFlatString& aProp, 
+                        nsAString& aResult)
+{
+  nsresult rv = NS_OK;
+
+  nsXPIDLString value;
+  rv = GetBundleValue(aBundle, aName, aProp, getter_Copies(value));
+  if (NS_FAILED(rv))
+    return rv;
+
+  aResult = value;
+
+  return NS_OK;
+}
+
+static
+nsresult GetCharsetDataImpl(const char * aCharset, const char16_t * aProp,
+                            nsAString& aResult)
+{
+  NS_ENSURE_ARG_POINTER(aCharset);
+  // aProp can be nullptr
+
+  if (!sDataBundle) {
+    nsresult rv = LoadExtensibleBundle(NS_DATA_BUNDLE_CATEGORY, &sDataBundle);
+    if (NS_FAILED(rv))
+      return rv;
+  }
+
+  return GetBundleValue(sDataBundle, aCharset, nsDependentString(aProp), aResult);
+}
+
+//static
+bool nsCharsetConverterManager::IsInternal(const nsACString& aCharset)
+{
+  nsAutoString str;
+  // fully qualify to possibly avoid vtable call
+  nsresult rv = GetCharsetDataImpl(PromiseFlatCString(aCharset).get(),
+                                   MOZ_UTF16(".isInternal"),
+                                   str);
+
+  return NS_SUCCEEDED(rv);
+}
+
+
+//----------------------------------------------------------------------------//----------------------------------------------------------------------------
+// Interface nsICharsetConverterManager [implementation]
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetUnicodeEncoder(const char * aDest, 
+                                             nsIUnicodeEncoder ** aResult)
+{
+  // resolve the charset first
+  nsAutoCString charset;
+  
+  // fully qualify to possibly avoid vtable call
+  nsCharsetConverterManager::GetCharsetAlias(aDest, charset);
+
+  return nsCharsetConverterManager::GetUnicodeEncoderRaw(charset.get(),
+                                                         aResult);
+}
+
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetUnicodeEncoderRaw(const char * aDest, 
+                                                nsIUnicodeEncoder ** aResult)
+{
+  *aResult= nullptr;
+  nsCOMPtr<nsIUnicodeEncoder> encoder;
+
+  nsresult rv = NS_OK;
+
+  nsAutoCString
+    contractid(NS_LITERAL_CSTRING(NS_UNICODEENCODER_CONTRACTID_BASE) +
+               nsDependentCString(aDest));
+
+  // Always create an instance since encoders hold state.
+  encoder = do_CreateInstance(contractid.get(), &rv);
+
+  if (NS_FAILED(rv))
+    rv = NS_ERROR_UCONV_NOCONV;
+  else
+  {
+    *aResult = encoder.get();
+    NS_ADDREF(*aResult);
+  }
+  return rv;
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetUnicodeDecoder(const char * aSrc, 
+                                             nsIUnicodeDecoder ** aResult)
+{
+  // resolve the charset first
+  nsAutoCString charset;
+
+  // fully qualify to possibly avoid vtable call
+  if (NS_FAILED(nsCharsetConverterManager::GetCharsetAlias(aSrc, charset)))
+    return NS_ERROR_UCONV_NOCONV;
+
+  return nsCharsetConverterManager::GetUnicodeDecoderRaw(charset.get(),
+                                                         aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetUnicodeDecoderInternal(const char * aSrc, 
+                                                     nsIUnicodeDecoder ** aResult)
+{
+  // resolve the charset first
+  nsAutoCString charset;
+
+  nsresult rv = nsCharsetAlias::GetPreferredInternal(nsDependentCString(aSrc),
+                                                     charset);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return nsCharsetConverterManager::GetUnicodeDecoderRaw(charset.get(),
+                                                         aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetUnicodeDecoderRaw(const char * aSrc, 
+                                                nsIUnicodeDecoder ** aResult)
+{
+  *aResult= nullptr;
+  nsCOMPtr<nsIUnicodeDecoder> decoder;
+
+  nsresult rv = NS_OK;
+
+  NS_NAMED_LITERAL_CSTRING(contractbase, NS_UNICODEDECODER_CONTRACTID_BASE);
+  nsDependentCString src(aSrc);
+
+  decoder = do_CreateInstance(PromiseFlatCString(contractbase + src).get(),
+                              &rv);
+  NS_ENSURE_SUCCESS(rv, NS_ERROR_UCONV_NOCONV);
+
+  decoder.forget(aResult);
+  return rv;
+}
+
+static
+nsresult GetList(const nsACString& aCategory,
+                 const nsACString& aPrefix,
+                 nsIUTF8StringEnumerator** aResult)
+{
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = nullptr;
+
+  nsresult rv;
+
+  nsCOMPtr<nsICategoryManager> catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
+  if (NS_FAILED(rv))
+    return rv;
+
+  nsTArray<nsCString>* array = new nsTArray<nsCString>;
+  if (!array)
+    return NS_ERROR_OUT_OF_MEMORY;
+  
+  nsCOMPtr<nsISimpleEnumerator> enumerator;
+  catman->EnumerateCategory(PromiseFlatCString(aCategory).get(), 
+                            getter_AddRefs(enumerator));
+
+  bool hasMore;
+  while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) {
+    nsCOMPtr<nsISupports> supports;
+    if (NS_FAILED(enumerator->GetNext(getter_AddRefs(supports))))
+      continue;
+    
+    nsCOMPtr<nsISupportsCString> supStr = do_QueryInterface(supports);
+    if (!supStr)
+      continue;
+
+    nsAutoCString name;
+    if (NS_FAILED(supStr->GetData(name)))
+      continue;
+
+    nsAutoCString fullName(aPrefix);
+    fullName.Append(name);
+    NS_ENSURE_TRUE(array->AppendElement(fullName), NS_ERROR_OUT_OF_MEMORY);
+  }
+    
+  return NS_NewAdoptingUTF8StringEnumerator(aResult, array);
+}
+
+// we should change the interface so that we can just pass back a enumerator!
+NS_IMETHODIMP
+nsCharsetConverterManager::GetDecoderList(nsIUTF8StringEnumerator ** aResult)
+{
+  return GetList(NS_LITERAL_CSTRING(NS_UNICODEDECODER_NAME),
+                 EmptyCString(), aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetEncoderList(nsIUTF8StringEnumerator ** aResult)
+{
+  return GetList(NS_LITERAL_CSTRING(NS_UNICODEENCODER_NAME),
+                 EmptyCString(), aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetDetectorList(nsIUTF8StringEnumerator** aResult)
+{
+  return GetList(NS_LITERAL_CSTRING("charset-detectors"),
+                 NS_LITERAL_CSTRING("chardet."), aResult);
+}
+
+// XXX Improve the implementation of this method. Right now, it is build on 
+// top of the nsCharsetAlias service. We can make the nsCharsetAlias
+// better, with its own hash table (not the StringBundle anymore) and
+// a nicer file format.
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetAlias(const char * aCharset, 
+                                           nsACString& aResult)
+{
+  NS_ENSURE_ARG_POINTER(aCharset);
+
+  // We try to obtain the preferred name for this charset from the charset 
+  // aliases.
+  nsresult rv;
+
+  rv = nsCharsetAlias::GetPreferred(nsDependentCString(aCharset), aResult);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  return NS_OK;
+}
+
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetTitle(const char * aCharset, 
+                                           nsAString& aResult)
+{
+  NS_ENSURE_ARG_POINTER(aCharset);
+
+  if (!sTitleBundle) {
+    nsresult rv = LoadExtensibleBundle(NS_TITLE_BUNDLE_CATEGORY, &sTitleBundle);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  return GetBundleValue(sTitleBundle, aCharset, NS_LITERAL_STRING(".title"), aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetData(const char * aCharset, 
+                                          const char16_t * aProp,
+                                          nsAString& aResult)
+{
+  return GetCharsetDataImpl(aCharset, aProp, aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetLangGroup(const char * aCharset, 
+                                               nsIAtom** aResult)
+{
+  // resolve the charset first
+  nsAutoCString charset;
+
+  nsresult rv = GetCharsetAlias(aCharset, charset);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // fully qualify to possibly avoid vtable call
+  return nsCharsetConverterManager::GetCharsetLangGroupRaw(charset.get(),
+                                                           aResult);
+}
+
+NS_IMETHODIMP
+nsCharsetConverterManager::GetCharsetLangGroupRaw(const char * aCharset, 
+                                                  nsIAtom** aResult)
+{
+
+  *aResult = nullptr;
+  nsAutoString langGroup;
+  // fully qualify to possibly avoid vtable call
+  nsresult rv = nsCharsetConverterManager::GetCharsetData(
+      aCharset, MOZ_UTF16(".LangGroup"), langGroup);
+
+  if (NS_SUCCEEDED(rv)) {
+    ToLowerCase(langGroup); // use lowercase for all language atoms
+    *aResult = NS_NewAtom(langGroup).take();
+  }
+
+  return rv;
+}
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/nsCharsetConverterManager.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+#ifndef nsCharsetConverterManager_h__
+#define nsCharsetConverterManager_h__
+
+#include "nsISupports.h"
+#include "nsICharsetConverterManager.h"
+
+#define NS_DATA_BUNDLE_CATEGORY     "uconv-charset-data"
+#define NS_TITLE_BUNDLE_CATEGORY    "uconv-charset-titles"
+
+class nsCharsetAlias;
+
+class nsCharsetConverterManager : public nsICharsetConverterManager
+{
+  friend class nsCharsetAlias;
+
+  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_NSICHARSETCONVERTERMANAGER
+
+public:
+  nsCharsetConverterManager();
+  virtual ~nsCharsetConverterManager();
+
+  static void Shutdown();
+
+private:
+
+  static bool IsInternal(const nsACString& aCharset);
+};
+
+#endif // nsCharsetConverterManager_h__
+
+
new file mode 100644
--- /dev/null
+++ b/mailnews/intl/nsICharsetConverterManager.idl
@@ -0,0 +1,110 @@
+/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsISupports.idl"
+#include "nsIAtom.idl"
+
+%{ C++
+#include "nsIUnicodeDecoder.h"
+#include "nsIUnicodeEncoder.h"
+
+// XXX change to NS_CHARSETCONVERTERMANAGER_CID
+#define NS_ICHARSETCONVERTERMANAGER_CID \
+  {0x3c1c0163, 0x9bd0, 0x11d3, { 0x9d, 0x9, 0x0, 0x50, 0x4, 0x0, 0x7, 0xb2}}
+
+#define NS_CHARSETCONVERTERMANAGER_CONTRACTID "@mozilla.org/charset-converter-manager;1"
+%}
+
+interface nsIUnicodeDecoder;
+interface nsIUnicodeEncoder;
+interface nsIUTF8StringEnumerator;
+
+/**
+ * DON'T ADD NEW USES OF THIS INTERFACE TO MOZILLA-CENTRAL. Use 
+ * mozilla::dom::EncodingUtils instead.
+ *
+ * Here Charsets are identified by ASCII strings. Charset alias
+ * resolution is provided by default in most methods. "Raw"
+ * versions that do not need this resolution are also provided.
+ *
+ * @deprecated Use mozilla::dom::EncodingUtils in mozilla-central instead.
+ * @created         21/Feb/2000
+ * @author  Catalin Rotaru [CATA]
+ */
+[scriptable, uuid(a0550d46-8d9c-47dd-acc7-c083620dff12)]
+interface nsICharsetConverterManager : nsISupports
+{
+    /**
+     * Get the Unicode decoder for the given charset.
+     * The "Raw" version skips charset alias resolution
+     */
+    [noscript] nsIUnicodeDecoder getUnicodeDecoder(in string charset);
+    [noscript] nsIUnicodeDecoder getUnicodeDecoderRaw(in string charset);
+    [noscript] nsIUnicodeDecoder getUnicodeDecoderInternal(in string charset);
+
+    /**
+     * Get the Unicode encoder for the given charset.
+     * The "Raw" version skips charset alias resolution
+     */
+    [noscript] nsIUnicodeEncoder getUnicodeEncoder(in string charset);
+    [noscript] nsIUnicodeEncoder getUnicodeEncoderRaw(in string charset);
+
+    /**
+     * A shortcut to calling nsICharsetAlias to do alias resolution
+     * @throws if aCharset is an unknown charset.
+     */
+    ACString getCharsetAlias(in string aCharset);
+    
+    /**
+     * Get the complete list of available decoders.
+     */
+    nsIUTF8StringEnumerator getDecoderList();
+
+    /**
+     * Get the complete list of available encoders.
+     */
+    nsIUTF8StringEnumerator getEncoderList();
+
+    /**
+     * Get the complete list of available charset detectors.
+     */
+    nsIUTF8StringEnumerator GetCharsetDetectorList();
+
+    /**
+     * Get the human-readable name for the given charset.
+     * @throws if aCharset is an unknown charset.
+     */
+    AString getCharsetTitle(in string aCharset);
+
+    /**
+     * Get some data about the given charset. This includes whether the 
+     * character encoding may be used for certain purposes, if it is 
+     * multi-byte, and the language code for it. See charsetData.properties
+     * for the source of this data. Some known property names:
+     *    notForBrowser  - not to be used in the browser.
+     *    notForOutgoing - not to be used for exporting files.
+     *    LangGroup      - language code for charset, e.g. 'he' and 'zh-CN'.
+     *    isMultibyte    - is this a multi-byte charset?
+     *    isInternal     - not to be used in untrusted web content.
+     * 
+     * @param aCharset name of the character encoding, e.g. 'iso-8859-15'.
+     * @param aProp property desired for the character encoding.
+     * @throws if aCharset is an unknown charset.
+     * @return the value of the property, for the character encoding.
+     */
+    AString getCharsetData(in string aCharset, 
+                           in wstring aProp);
+
+    /**
+     * Get the language group for the given charset. This is similar to 
+     * calling <tt>getCharsetData</tt> with the <tt>prop</tt> "LangGroup".
+     * 
+     * @param aCharset name of the character encoding, e.g. 'iso-8859-15'.
+     * @throws if aCharset is an unknown charset.
+     * @return the language code for the character encoding.
+     */
+    nsIAtom getCharsetLangGroup(in string aCharset);
+    nsIAtom getCharsetLangGroupRaw(in string aCharset);
+};
new file mode 100644
--- /dev/null
+++ b/suite/locales/en-US/chrome/mailnews/charsetTitles.properties
@@ -0,0 +1,104 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+## Rule of this file:
+## 1. key should always be in lower case ascii so we can do case insensitive
+##    comparison in the code faster.
+
+## Format of this file:
+## charset_name.title = a_title  -  specifies the human readable title for 
+## this charset
+
+us-ascii.title    = English (US-ASCII)
+iso-8859-1.title    = Western (ISO-8859-1)
+iso-8859-2.title    = Central European (ISO-8859-2)
+iso-8859-3.title    = South European (ISO-8859-3)
+iso-8859-4.title    = Baltic (ISO-8859-4)
+iso-8859-9.title    = Turkish (ISO-8859-9)
+iso-8859-10.title   = Nordic (ISO-8859-10)
+iso-8859-13.title   = Baltic (ISO-8859-13)
+iso-8859-14.title   = Celtic (ISO-8859-14)
+iso-8859-15.title   = Western (ISO-8859-15)
+iso-8859-16.title   = Romanian (ISO-8859-16)
+windows-1250.title  = Central European (Windows-1250)
+windows-1252.title  = Western (Windows-1252)
+windows-1254.title  = Turkish (Windows-1254)
+windows-1257.title  = Baltic (Windows-1257)
+macintosh.title         = Western (MacRoman)
+x-mac-ce.title          = Central European (MacCE)
+x-mac-turkish.title     = Turkish (MacTurkish)
+x-mac-croatian.title    = Croatian (MacCroatian)
+x-mac-romanian.title    = Romanian (MacRomanian)
+x-mac-icelandic.title   = Icelandic (MacIcelandic)
+iso-2022-jp.title = Japanese (ISO-2022-JP)
+shift_jis.title = Japanese (Shift_JIS)
+euc-jp.title = Japanese (EUC-JP)
+big5.title = Chinese Traditional (Big5)
+big5-hkscs.title = Chinese Traditional (Big5-HKSCS)
+x-euc-tw.title = Chinese Traditional (EUC-TW)
+gb2312.title = Chinese Simplified (GB2312)
+hz-gb-2312.title = Chinese Simplified (HZ)
+gbk.title = Chinese Simplified (GBK)
+iso-2022-cn.title = Chinese Simplified (ISO-2022-CN)
+euc-kr.title = Korean (EUC-KR)
+x-johab.title = Korean (JOHAB)
+iso-2022-kr.title = Korean (ISO-2022-KR)
+utf-7.title = Unicode (UTF-7)
+utf-8.title = Unicode (UTF-8)
+utf-16.title = Unicode (UTF-16)
+utf-16le.title = Unicode (UTF-16LE)
+utf-16be.title = Unicode (UTF-16BE)
+iso-8859-5.title = Cyrillic (ISO-8859-5)
+iso-ir-111.title = Cyrillic (ISO-IR-111)
+windows-1251.title = Cyrillic (Windows-1251)
+x-mac-cyrillic.title = Cyrillic (MacCyrillic)
+x-mac-ukrainian.title = Cyrillic/Ukrainian (MacUkrainian)
+koi8-r.title = Cyrillic (KOI8-R)
+koi8-u.title = Cyrillic/Ukrainian (KOI8-U)
+iso-8859-7.title = Greek (ISO-8859-7)
+windows-1253.title = Greek (Windows-1253)
+x-mac-greek.title = Greek (MacGreek)
+windows-1258.title = Vietnamese (Windows-1258)
+x-viet-tcvn5712.title = Vietnamese (TCVN)
+viscii.title = Vietnamese (VISCII)
+x-viet-vps.title = Vietnamese (VPS)
+tis-620.title = Thai (TIS-620)
+iso-8859-11.title = Thai (ISO-8859-11)
+windows-874.title = Thai (Windows-874)
+ibm874.title = Thai (IBM-874)
+armscii-8.title = Armenian (ARMSCII-8)
+iso-8859-6.title = Arabic (ISO-8859-6)
+iso-8859-6-i.title = Arabic (ISO-8859-6-I)
+iso-8859-6-e.title = Arabic (ISO-8859-6-E)
+iso-8859-8.title = Hebrew Visual (ISO-8859-8)
+iso-8859-8-i.title = Hebrew (ISO-8859-8-I)
+iso-8859-8-e.title = Hebrew (ISO-8859-8-E)
+windows-1255.title = Hebrew (Windows-1255)
+windows-1256.title = Arabic (Windows-1256)
+x-user-defined.title = User Defined
+ibm866.title = Cyrillic/Russian (CP-866)
+ibm850.title = Western (IBM-850)
+ibm852.title = Central European (IBM-852)
+ibm855.title = Cyrillic (IBM-855)
+ibm857.title = Turkish (IBM-857)
+ibm862.title = Hebrew (IBM-862)
+gb18030.title = Chinese Simplified (GB18030)
+x-mac-arabic.title = Arabic (MacArabic)
+x-mac-farsi.title = Farsi (MacFarsi)
+x-mac-hebrew.title = Hebrew (MacHebrew)
+x-mac-devanagari.title = Hindi (MacDevanagari)
+x-mac-gujarati.title = Gujarati (MacGujarati)
+x-mac-gurmukhi.title = Gurmukhi (MacGurmukhi)
+
+
+chardet.off.title                           = (Off)
+chardet.universal_charset_detector.title    = Universal
+chardet.ja_parallel_state_machine.title     = Japanese
+chardet.ko_parallel_state_machine.title     = Korean
+chardet.zhtw_parallel_state_machine.title   = Traditional Chinese
+chardet.zhcn_parallel_state_machine.title   = Simplified Chinese
+chardet.zh_parallel_state_machine.title     = Chinese
+chardet.cjk_parallel_state_machine.title    = East Asian
+chardet.ruprob.title                        = Russian
+chardet.ukprob.title                        = Ukrainian
--- a/suite/locales/jar.mn
+++ b/suite/locales/jar.mn
@@ -243,16 +243,17 @@
   locale/@AB_CD@/messenger/am-mdn.dtd                                       (%chrome/mailnews/pref/am-mdn.dtd)
   locale/@AB_CD@/messenger/am-mdn.properties                                (%chrome/mailnews/pref/am-mdn.properties)
   locale/@AB_CD@/messenger/am-offline.dtd                                   (%chrome/mailnews/pref/am-offline.dtd)
   locale/@AB_CD@/messenger/am-serverwithnoidentities.dtd                    (%chrome/mailnews/pref/am-serverwithnoidentities.dtd)
   locale/@AB_CD@/messenger/am-server-advanced.dtd                           (%chrome/mailnews/pref/am-server-advanced.dtd)
   locale/@AB_CD@/messenger/am-server-top.dtd                                (%chrome/mailnews/pref/am-server-top.dtd)
   locale/@AB_CD@/messenger/am-archiveoptions.dtd                            (%chrome/mailnews/pref/am-archiveoptions.dtd)
   locale/@AB_CD@/messenger/appleMailImportMsgs.properties                   (%chrome/mailnews/appleMailImportMsgs.properties)
+  locale/@AB_CD@/messenger/charsetTitles.properties                         (%chrome/mailnews/charsetTitles.properties)
   locale/@AB_CD@/messenger/custom.properties                                (%chrome/mailnews/custom.properties)
   locale/@AB_CD@/messenger/CustomHeaders.dtd                                (%chrome/mailnews/CustomHeaders.dtd)
   locale/@AB_CD@/messenger/eudoraImportMsgs.properties                      (%chrome/mailnews/eudoraImportMsgs.properties)
   locale/@AB_CD@/messenger/downloadheaders.dtd                              (%chrome/mailnews/downloadheaders.dtd)
   locale/@AB_CD@/messenger/fieldMapImport.dtd                               (%chrome/mailnews/fieldMapImport.dtd)
   locale/@AB_CD@/messenger/filter.properties                                (%chrome/mailnews/filter.properties)
   locale/@AB_CD@/messenger/FilterEditor.dtd                                 (%chrome/mailnews/FilterEditor.dtd)
   locale/@AB_CD@/messenger/FilterListDialog.dtd                             (%chrome/mailnews/FilterListDialog.dtd)