mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 943268 - Remove nsCharsetAlias and nsCharsetConverterManager. r=emk.
This commit is contained in:
parent
aa51d61f09
commit
97f4c4b92d
@ -57,14 +57,12 @@ relativesrcdir toolkit/locales:
|
||||
|
||||
# overrides for dom l10n, also for en-US
|
||||
relativesrcdir dom/locales:
|
||||
locale/@AB_CD@/b2g-l10n/overrides/charsetTitles.properties (%chrome/charsetTitles.properties)
|
||||
locale/@AB_CD@/b2g-l10n/overrides/global.dtd (%chrome/global.dtd)
|
||||
locale/@AB_CD@/b2g-l10n/overrides/AccessFu.properties (%chrome/accessibility/AccessFu.properties)
|
||||
locale/@AB_CD@/b2g-l10n/overrides/dom/dom.properties (%chrome/dom/dom.properties)
|
||||
#about:plugins
|
||||
locale/@AB_CD@/b2g-l10n/overrides/plugins.properties (%chrome/plugins.properties)
|
||||
|
||||
% override chrome://global/locale/charsetTitles.properties chrome://b2g-l10n/locale/overrides/charsetTitles.properties
|
||||
% override chrome://global/locale/global.dtd chrome://b2g-l10n/locale/overrides/global.dtd
|
||||
% override chrome://global/locale/AccessFu.properties chrome://b2g-l10n/locale/overrides/AccessFu.properties
|
||||
% override chrome://global/locale/dom/dom.properties chrome://b2g-l10n/locale/overrides/dom/dom.properties
|
||||
|
@ -20,9 +20,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ShortcutUtils",
|
||||
"resource://gre/modules/ShortcutUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
"resource://gre/modules/CharsetMenu.jsm");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "CharsetManager",
|
||||
"@mozilla.org/charset-converter-manager;1",
|
||||
"nsICharsetConverterManager");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "CharsetBundle", function() {
|
||||
const kCharsetBundle = "chrome://global/locale/charsetMenu.properties";
|
||||
|
@ -114,7 +114,6 @@
|
||||
#include "nsIRequest.h"
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
|
||||
#include "nsCharsetAlias.h"
|
||||
#include "nsCharsetSource.h"
|
||||
#include "nsIParser.h"
|
||||
#include "nsIContentSink.h"
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include "nscore.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -31,7 +29,6 @@
|
||||
#include "nsRange.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIParserService.h"
|
||||
@ -53,6 +50,7 @@
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIHTMLEditor.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -150,7 +148,6 @@ protected:
|
||||
nsCOMPtr<nsIUnicodeEncoder> mUnicodeEncoder;
|
||||
nsCOMPtr<nsINode> mCommonParent;
|
||||
nsCOMPtr<nsIDocumentEncoderNodeFixup> mNodeFixup;
|
||||
nsCOMPtr<nsICharsetConverterManager> mCharsetConverterManager;
|
||||
|
||||
nsString mMimeType;
|
||||
nsCString mCharset;
|
||||
@ -1064,12 +1061,6 @@ nsDocumentEncoder::EncodeToStringWithMaxLength(uint32_t aMaxLength,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIAtom> charsetAtom;
|
||||
if (!mCharset.IsEmpty()) {
|
||||
if (!mCharsetConverterManager) {
|
||||
mCharsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
bool rewriteEncodingDeclaration = !(mSelection || mRange || mNode) && !(mFlags & OutputDontRewriteEncodingDeclaration);
|
||||
mSerializer->Init(mFlags, mWrapColumn, mCharset.get(), mIsCopying, rewriteEncodingDeclaration);
|
||||
@ -1204,14 +1195,11 @@ nsDocumentEncoder::EncodeToStream(nsIOutputStream* aStream)
|
||||
if (!mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
if (!mCharsetConverterManager) {
|
||||
mCharsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(mCharset, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
|
||||
rv = mCharsetConverterManager->GetUnicodeEncoder(mCharset.get(),
|
||||
getter_AddRefs(mUnicodeEncoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mUnicodeEncoder = EncodingUtils::EncoderForEncoding(encoding);
|
||||
|
||||
if (mMimeType.LowerCaseEqualsLiteral("text/plain")) {
|
||||
rv = mUnicodeEncoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nullptr, '?');
|
||||
|
@ -36,8 +36,8 @@ ArchiveReader::Constructor(const GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabel(aOptions.mEncoding, encoding) ||
|
||||
encoding.EqualsLiteral("replacement")) {
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aOptions.mEncoding,
|
||||
encoding)) {
|
||||
aError.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &aOptions.mEncoding);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -17,6 +17,10 @@ static const char* labelsEncodings[][3] = {
|
||||
#include "labelsencodings.properties.h"
|
||||
};
|
||||
|
||||
static const char* encodingsGroups[][3] = {
|
||||
#include "encodingsgroups.properties.h"
|
||||
};
|
||||
|
||||
bool
|
||||
EncodingUtils::FindEncodingForLabel(const nsACString& aLabel,
|
||||
nsACString& aOutEncoding)
|
||||
@ -35,6 +39,20 @@ EncodingUtils::FindEncodingForLabel(const nsACString& aLabel,
|
||||
labelsEncodings, ArrayLength(labelsEncodings), label, aOutEncoding));
|
||||
}
|
||||
|
||||
bool
|
||||
EncodingUtils::FindEncodingForLabelNoReplacement(const nsACString& aLabel,
|
||||
nsACString& aOutEncoding)
|
||||
{
|
||||
if(!FindEncodingForLabel(aLabel, aOutEncoding)) {
|
||||
return false;
|
||||
}
|
||||
if (aOutEncoding.EqualsLiteral("replacement")) {
|
||||
aOutEncoding.Truncate();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
EncodingUtils::IsAsciiCompatible(const nsACString& aPreferredName)
|
||||
{
|
||||
@ -69,5 +87,15 @@ EncodingUtils::EncoderForEncoding(const nsACString& aEncoding)
|
||||
return encoder.forget();
|
||||
}
|
||||
|
||||
void
|
||||
EncodingUtils::LangGroupForEncoding(const nsACString& aEncoding,
|
||||
nsACString& aOutGroup)
|
||||
{
|
||||
if (NS_FAILED(nsUConvPropertySearch::SearchPropertyValue(
|
||||
encodingsGroups, ArrayLength(encodingsGroups), aEncoding, aOutGroup))) {
|
||||
aOutGroup.AssignLiteral("x-unicode");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
* our internal implementations.
|
||||
*
|
||||
* @param aLabel, incoming label describing charset to be decoded.
|
||||
* @param aRetEncoding, returning corresponding encoding for label.
|
||||
* @param aOutEncoding, returning corresponding encoding for label.
|
||||
* @return false if no encoding was found for label.
|
||||
* true if valid encoding found.
|
||||
*/
|
||||
@ -40,6 +40,25 @@ public:
|
||||
return FindEncodingForLabel(NS_ConvertUTF16toUTF8(aLabel), aOutEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like FindEncodingForLabel() except labels that map to "replacement"
|
||||
* are treated as unknown.
|
||||
*
|
||||
* @param aLabel, incoming label describing charset to be decoded.
|
||||
* @param aOutEncoding, returning corresponding encoding for label.
|
||||
* @return false if no encoding was found for label.
|
||||
* true if valid encoding found.
|
||||
*/
|
||||
static bool FindEncodingForLabelNoReplacement(const nsACString& aLabel,
|
||||
nsACString& aOutEncoding);
|
||||
|
||||
static bool FindEncodingForLabelNoReplacement(const nsAString& aLabel,
|
||||
nsACString& aOutEncoding)
|
||||
{
|
||||
return FindEncodingForLabelNoReplacement(NS_ConvertUTF16toUTF8(aLabel),
|
||||
aOutEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any leading and trailing space characters, following the
|
||||
* definition of space characters from Encoding spec.
|
||||
@ -109,6 +128,16 @@ public:
|
||||
static already_AddRefed<nsIUnicodeEncoder>
|
||||
EncoderForEncoding(const nsACString& aEncoding);
|
||||
|
||||
/**
|
||||
* Finds a Gecko language group string (e.g. x-western) for a Gecko-canonical
|
||||
* encoding name.
|
||||
*
|
||||
* @param aEncoding, incoming label describing charset to be decoded.
|
||||
* @param aOutGroup, returning corresponding language group.
|
||||
*/
|
||||
static void LangGroupForEncoding(const nsACString& aEncoding,
|
||||
nsACString& aOutGroup);
|
||||
|
||||
private:
|
||||
EncodingUtils() MOZ_DELETE;
|
||||
};
|
||||
|
@ -11,5 +11,7 @@ localesfallbacks.properties.h: $(PROPS2ARRAYS) localesfallbacks.properties
|
||||
$(PYTHON) $^ $@
|
||||
domainsfallbacks.properties.h: $(PROPS2ARRAYS) domainsfallbacks.properties
|
||||
$(PYTHON) $^ $@
|
||||
encodingsgroups.properties.h: $(PROPS2ARRAYS) encodingsgroups.properties
|
||||
$(PYTHON) $^ $@
|
||||
nonparticipatingdomains.properties.h: $(PROPS2ARRAYS) nonparticipatingdomains.properties
|
||||
$(PYTHON) $^ $@
|
||||
|
@ -15,14 +15,12 @@ void
|
||||
TextDecoder::Init(const nsAString& aLabel, const bool aFatal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsAutoString label(aLabel);
|
||||
EncodingUtils::TrimSpaceCharacters(label);
|
||||
|
||||
nsAutoCString encoding;
|
||||
// Let encoding be the result of getting an encoding from label.
|
||||
// If encoding is failure or replacement, throw a TypeError.
|
||||
if (!EncodingUtils::FindEncodingForLabel(label, encoding) ||
|
||||
encoding.EqualsLiteral("replacement")) {
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aLabel, encoding)) {
|
||||
nsAutoString label(aLabel);
|
||||
EncodingUtils::TrimSpaceCharacters(label);
|
||||
aRv.ThrowTypeError(MSG_ENCODING_NOT_SUPPORTED, &label);
|
||||
return;
|
||||
}
|
||||
|
43
dom/encoding/encodingsgroups.properties
Normal file
43
dom/encoding/encodingsgroups.properties
Normal file
@ -0,0 +1,43 @@
|
||||
# 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/.
|
||||
|
||||
# x-unicode is assumed for encodings not listed here
|
||||
|
||||
Big5=zh-TW
|
||||
Big5-HKSCS=zh=HK
|
||||
EUC-JP=ja
|
||||
EUC-KR=ko
|
||||
gb18030=zh-CN
|
||||
gbk=zh-CN
|
||||
HZ-GB-2312=zh-CN
|
||||
IBM866=x-cyrillic
|
||||
ISO-2022-JP=ja
|
||||
ISO-8859-3=x-western
|
||||
ISO-8859-4=x-baltic
|
||||
ISO-8859-5=x-cyrillic
|
||||
ISO-8859-6=ar
|
||||
ISO-8859-7=el
|
||||
ISO-8859-8=he
|
||||
ISO-8859-8-I=he
|
||||
ISO-8859-10=x-western
|
||||
ISO-8859-13=x-baltic
|
||||
ISO-8859-14=x-western
|
||||
ISO-8859-15=x-western
|
||||
ISO-8859-16=x-central-euro
|
||||
ISO-8859-2=x-central-euro
|
||||
KOI8-R=x-cyrillic
|
||||
KOI8-U=x-cyrillic
|
||||
Shift_JIS=ja
|
||||
windows-1250=x-central-euro
|
||||
windows-1251=x-cyrillic
|
||||
windows-1252=x-western
|
||||
windows-1253=el
|
||||
windows-1254=tr
|
||||
windows-1255=he
|
||||
windows-1256=ar
|
||||
windows-1257=x-baltic
|
||||
windows-1258=x-western
|
||||
windows-874=th
|
||||
x-mac-cyrillic=x-cyrillic
|
||||
|
@ -29,6 +29,7 @@ LOCAL_INCLUDES += [
|
||||
|
||||
GENERATED_FILES += [
|
||||
'domainsfallbacks.properties.h',
|
||||
'encodingsgroups.properties.h',
|
||||
'labelsencodings.properties.h',
|
||||
'localesfallbacks.properties.h',
|
||||
'nonparticipatingdomains.properties.h',
|
||||
|
@ -1,104 +0,0 @@
|
||||
# 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
|
@ -14,7 +14,6 @@
|
||||
locale/@AB_CD@/global/netErrorApp.dtd (%chrome/netErrorApp.dtd)
|
||||
locale/@AB_CD@/global/global.dtd (%chrome/global.dtd)
|
||||
locale/@AB_CD@/global/appstrings.properties (%chrome/appstrings.properties)
|
||||
locale/@AB_CD@/global/charsetTitles.properties (%chrome/charsetTitles.properties)
|
||||
locale/@AB_CD@/global/global-strres.properties (%chrome/global-strres.properties)
|
||||
locale/@AB_CD@/global/plugins.properties (%chrome/plugins.properties)
|
||||
locale/@AB_CD@/global/nsWebBrowserPersist.properties (%chrome/nsWebBrowserPersist.properties)
|
||||
|
@ -8,18 +8,18 @@
|
||||
#include "prlink.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIPluginInstanceOwner.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsPluginsDir.h"
|
||||
#include "nsPluginHost.h"
|
||||
#include "nsIBlocklistService.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsPluginLogging.h"
|
||||
#include "nsNPAPIPlugin.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include <cctype>
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
using namespace mozilla;
|
||||
|
||||
// These legacy flags are used in the plugin registry. The states are now
|
||||
@ -236,17 +236,12 @@ nsresult nsPluginTag::EnsureMembersAreUTF8()
|
||||
do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoCString charset;
|
||||
rv = pcs->GetCharset(kPlatformCharsetSel_FileName, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!charset.LowerCaseEqualsLiteral("utf-8")) {
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
decoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
ConvertToUTF8(decoder, mFileName);
|
||||
ConvertToUTF8(decoder, mFullPath);
|
||||
}
|
||||
@ -257,9 +252,7 @@ nsresult nsPluginTag::EnsureMembersAreUTF8()
|
||||
rv = pcs->GetCharset(kPlatformCharsetSel_PlainTextInFile, charset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!charset.LowerCaseEqualsLiteral("utf-8")) {
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(decoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
decoder = EncodingUtils::DecoderForEncoding(charset);
|
||||
ConvertToUTF8(decoder, mName);
|
||||
ConvertToUTF8(decoder, mDescription);
|
||||
for (uint32_t i = 0; i < mMimeDescriptions.Length(); ++i) {
|
||||
|
@ -83,13 +83,12 @@ struct unicode_info {
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
using mozilla::dom::EncodingUtils;
|
||||
#endif
|
||||
|
||||
struct unicode_info2 {
|
||||
@ -5536,22 +5535,17 @@ struct cs_info * get_current_cs(const char * es) {
|
||||
nsCOMPtr<nsIUnicodeDecoder> decoder;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm = do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return ccs;
|
||||
|
||||
rv = ccm->GetUnicodeEncoder(es, getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
nsAutoCString label(es);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return ccs;
|
||||
}
|
||||
encoder = EncodingUtils::EncoderForEncoding(encoding);
|
||||
decoder = EncodingUtils::DecoderForEncoding(encoding);
|
||||
encoder->SetOutputErrorBehavior(encoder->kOnError_Signal, nullptr, '?');
|
||||
rv = ccm->GetUnicodeDecoder(es, getter_AddRefs(decoder));
|
||||
if (NS_FAILED(rv))
|
||||
return ccs;
|
||||
decoder->SetInputErrorBehavior(decoder->kOnError_Signal);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return ccs;
|
||||
|
||||
for (unsigned int i = 0; i <= 0xff; ++i) {
|
||||
bool success = false;
|
||||
// We want to find the upper/lowercase equivalents of each byte
|
||||
|
@ -67,7 +67,6 @@
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "mozISpellI18NManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsCRT.h"
|
||||
@ -76,6 +75,9 @@
|
||||
#include <stdlib.h>
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
|
||||
|
||||
@ -205,18 +207,13 @@ NS_IMETHODIMP mozHunspell::SetDictionary(const char16_t *aDictionary)
|
||||
if (!mHunspell)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ccm->GetUnicodeDecoder(mHunspell->get_dic_encoding(),
|
||||
getter_AddRefs(mDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ccm->GetUnicodeEncoder(mHunspell->get_dic_encoding(),
|
||||
getter_AddRefs(mEncoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsDependentCString label(mHunspell->get_dic_encoding());
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(encoding);
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(encoding);
|
||||
|
||||
if (mEncoder)
|
||||
mEncoder->SetOutputErrorBehavior(mEncoder->kOnError_Signal, nullptr, '?');
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "nsLocaleConstructors.h"
|
||||
|
||||
// uconv
|
||||
#include "nsCharsetConverterManager.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsJISx4051LineBreaker)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSampleWordBreaker)
|
||||
@ -135,12 +134,6 @@ static const mozilla::Module::ContractIDEntry kIntlContracts[] = {
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static void
|
||||
I18nModuleDtor()
|
||||
{
|
||||
nsCharsetConverterManager::Shutdown();
|
||||
}
|
||||
|
||||
static const mozilla::Module kIntlModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kIntlCIDs,
|
||||
@ -148,7 +141,7 @@ static const mozilla::Module kIntlModule = {
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
I18nModuleDtor
|
||||
nullptr
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(nsI18nModule) = &kIntlModule;
|
||||
|
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'nsCharsetAlias.h',
|
||||
'nsCollationCID.h',
|
||||
'nsDateTimeFormatCID.h',
|
||||
'nsIDateTimeFormat.h',
|
||||
|
@ -1,25 +0,0 @@
|
||||
/* -*- 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___ */
|
@ -17,8 +17,8 @@
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#define NS_ILANGUAGEATOMSERVICE_IID \
|
||||
{0xAF4C48CF, 0x8F76, 0x4477, \
|
||||
{ 0xA7, 0x0E, 0xAB, 0x09, 0x74, 0xE2, 0x41, 0xF0 }}
|
||||
{0xcb3892a0, 0x6a76, 0x461c, \
|
||||
{ 0xb0, 0x24, 0x23, 0x0e, 0xe3, 0xe0, 0x81, 0x1a }}
|
||||
|
||||
#define NS_LANGUAGEATOMSERVICE_CONTRACTID \
|
||||
"@mozilla.org/intl/nslanguageatomservice;1"
|
||||
@ -31,7 +31,7 @@ class nsILanguageAtomService : public nsISupports
|
||||
virtual nsIAtom* LookupLanguage(const nsACString &aLanguage,
|
||||
nsresult *aError = nullptr) = 0;
|
||||
virtual already_AddRefed<nsIAtom>
|
||||
LookupCharSet(const char *aCharSet, nsresult *aError = nullptr) = 0;
|
||||
LookupCharSet(const nsACString& aCharSet) = 0;
|
||||
|
||||
virtual nsIAtom* GetLocaleLanguage(nsresult *aError = nullptr) = 0;
|
||||
|
||||
|
@ -9,6 +9,3 @@ endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
charsetalias.properties.h: props2arrays.py charsetalias.properties
|
||||
$(PYTHON) $^ $@
|
||||
|
||||
|
@ -1,460 +0,0 @@
|
||||
# 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
|
@ -18,7 +18,6 @@ EXPORTS += [
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsCharsetAlias.cpp',
|
||||
'nsCollation.cpp',
|
||||
'nsLanguageAtomService.cpp',
|
||||
'nsLocale.cpp',
|
||||
@ -35,10 +34,6 @@ MSVC_ENABLE_PGO = True
|
||||
|
||||
FINAL_LIBRARY = 'i18n'
|
||||
|
||||
GENERATED_FILES = [
|
||||
'charsetalias.properties.h',
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/intl/uconv/src',
|
||||
]
|
||||
|
@ -1,84 +0,0 @@
|
||||
/* -*- 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;
|
||||
}
|
@ -8,8 +8,10 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "prmem.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -73,13 +75,13 @@ nsresult nsCollation::SetCharset(const char* aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCharset);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr <nsICharsetConverterManager> charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = charsetConverterManager->GetUnicodeEncoder(aCharset,
|
||||
getter_AddRefs(mEncoder));
|
||||
nsDependentCString label(aCharset);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
return rv;
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(encoding);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsCollation::UnicodeToChar(const nsAString& aSrc, char** dst)
|
||||
|
@ -4,12 +4,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsLanguageAtomService.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsILocaleService.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLanguageAtomService, nsILanguageAtomService)
|
||||
|
||||
@ -44,31 +44,11 @@ nsLanguageAtomService::LookupLanguage(const nsACString &aLanguage,
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAtom>
|
||||
nsLanguageAtomService::LookupCharSet(const char *aCharSet, nsresult *aError)
|
||||
nsLanguageAtomService::LookupCharSet(const nsACString& aCharSet)
|
||||
{
|
||||
if (!mCharSets) {
|
||||
mCharSets = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
|
||||
if (!mCharSets) {
|
||||
if (aError)
|
||||
*aError = NS_ERROR_FAILURE;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> langGroup;
|
||||
mCharSets->GetCharsetLangGroup(aCharSet, getter_AddRefs(langGroup));
|
||||
if (!langGroup) {
|
||||
if (aError)
|
||||
*aError = NS_ERROR_FAILURE;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aError)
|
||||
*aError = NS_OK;
|
||||
|
||||
return langGroup.forget();
|
||||
nsAutoCString group;
|
||||
mozilla::dom::EncodingUtils::LangGroupForEncoding(aCharSet, group);
|
||||
return do_GetAtom(group);
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
|
@ -4,7 +4,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
@ -24,7 +23,7 @@ public:
|
||||
LookupLanguage(const nsACString &aLanguage, nsresult *aError);
|
||||
|
||||
virtual NS_HIDDEN_(already_AddRefed<nsIAtom>)
|
||||
LookupCharSet(const char *aCharSet, nsresult *aError);
|
||||
LookupCharSet(const nsACString& aCharSet);
|
||||
|
||||
virtual NS_HIDDEN_(nsIAtom*) GetLocaleLanguage(nsresult *aError);
|
||||
|
||||
@ -39,7 +38,6 @@ private:
|
||||
protected:
|
||||
NS_HIDDEN_(nsresult) InitLangGroupTable();
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> mCharSets;
|
||||
nsInterfaceHashtable<nsISupportsHashKey, nsIAtom> mLangToGroup;
|
||||
nsCOMPtr<nsIStringBundle> mLangGroups;
|
||||
nsCOMPtr<nsIAtom> mLocaleLanguage;
|
||||
|
@ -14,6 +14,9 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDateTimeFormatUnix, nsIDateTimeFormat)
|
||||
|
||||
@ -42,7 +45,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
|
||||
}
|
||||
}
|
||||
|
||||
mCharset.AssignLiteral("ISO-8859-1");
|
||||
mCharset.AssignLiteral("windows-1252");
|
||||
mPlatformLocale.Assign("en_US");
|
||||
|
||||
// get locale name string, use app default if no locale specified
|
||||
@ -81,12 +84,7 @@ nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize unicode decoder
|
||||
nsCOMPtr <nsICharsetConverterManager> charsetConverterManager;
|
||||
charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = charsetConverterManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mDecoder));
|
||||
}
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mCharset);
|
||||
|
||||
LocalePreferred24hour();
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
#define nsDateTimeFormatUnix_h__
|
||||
|
||||
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDateTimeFormat.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
|
||||
#define kPlatformLocaleLength 64
|
||||
|
||||
|
@ -11,11 +11,6 @@
|
||||
#include "nsUConvPropertySearch.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsEncoderDecoderUtils.h"
|
||||
#if HAVE_GNU_LIBC_VERSION_H
|
||||
#include <gnu/libc-version.h>
|
||||
@ -29,7 +24,9 @@
|
||||
#include "nsPlatformCharset.h"
|
||||
#include "prinit.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
using namespace mozilla;
|
||||
|
||||
static const char* kUnixCharsets[][3] = {
|
||||
@ -181,49 +178,11 @@ nsPlatformCharset::VerifyCharset(nsCString &aCharset)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult res;
|
||||
//
|
||||
// get the convert manager
|
||||
//
|
||||
nsCOMPtr <nsICharsetConverterManager> charsetConverterManager;
|
||||
charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
//
|
||||
// check if we can get an input converter
|
||||
//
|
||||
nsCOMPtr <nsIUnicodeEncoder> enc;
|
||||
res = charsetConverterManager->GetUnicodeEncoder(aCharset.get(), getter_AddRefs(enc));
|
||||
if (NS_FAILED(res)) {
|
||||
NS_ERROR("failed to create encoder");
|
||||
return res;
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aCharset, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
|
||||
//
|
||||
// check if we can get an output converter
|
||||
//
|
||||
nsCOMPtr <nsIUnicodeDecoder> dec;
|
||||
res = charsetConverterManager->GetUnicodeDecoder(aCharset.get(), getter_AddRefs(dec));
|
||||
if (NS_FAILED(res)) {
|
||||
NS_ERROR("failed to create decoder");
|
||||
return res;
|
||||
}
|
||||
|
||||
//
|
||||
// check if we recognize the charset string
|
||||
//
|
||||
|
||||
nsAutoCString result;
|
||||
res = charsetConverterManager->GetCharsetAlias(aCharset.get(), result);
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
//
|
||||
// return the preferred string
|
||||
//
|
||||
|
||||
aCharset.Assign(result);
|
||||
aCharset.Assign(encoding);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
## The key is "locale.all." + locale name
|
||||
# AIX
|
||||
locale.all.ar_AA=ISO-8859-6
|
||||
# AIX
|
||||
locale.all.Ar_AA=x-IBM1046
|
||||
# Solaris
|
||||
locale.all.Ar_ARM=ISO-8859-6
|
||||
locale.all.american.iso88591=ISO-8859-1
|
||||
@ -116,8 +114,6 @@ locale.all.En_JP=Shift_JIS
|
||||
locale.all.en_KR=EUC-KR
|
||||
locale.all.en_KR.IBM-eucKR=EUC-KR
|
||||
locale.all.en_TH=ISO-8859-1
|
||||
locale.all.en_TW=x-euc-tw
|
||||
locale.all.en_TW.IBM-eucTW=x-euc-tw
|
||||
locale.all.en_US=ISO-8859-1
|
||||
locale.all.en_US.88591=ISO-8859-1
|
||||
locale.all.en_US.ISO8859-1=ISO-8859-1
|
||||
@ -501,7 +497,6 @@ locale.all.sv_SE.iso885915=ISO-8859-15
|
||||
# HP
|
||||
locale.all.sv_SE.iso885915@euro=ISO-8859-15
|
||||
locale.all.sv_SE.ISO8859-1=ISO-8859-1
|
||||
locale.all.Sv_SE=IBM-850
|
||||
# AIX
|
||||
locale.all.swedish.iso88591=ISO-8859-1
|
||||
# Solaris
|
||||
@ -513,7 +508,6 @@ locale.all.th_TH=TIS-620
|
||||
locale.all.th_TH.TIS620=TIS-620
|
||||
locale.all.th=TIS-620
|
||||
locale.all.th_TH.UTF-8=UTF-8
|
||||
locale.all.tchinese=x-euc-tw
|
||||
# RedHat 7 reported by Garaschenko Slava <slava@maze.ambernet.kiev.ua bug 70601
|
||||
locale.all.uk_UA=KOI8-U
|
||||
locale.all.zh=GB2312
|
||||
@ -522,9 +516,7 @@ locale.all.zh_CN.EUC=GB2312
|
||||
locale.all.zh.GBK=gbk
|
||||
locale.all.zh_CN.UTF-8=UTF-8
|
||||
locale.all.zh.UTF-8=UTF-8
|
||||
locale.all.zh_TW.EUC=x-euc-tw
|
||||
locale.all.zh_TW.BIG5=Big5
|
||||
locale.all.zh_HK.HKSCS=x-hkscs
|
||||
# saw the following name from news://xcin.linux.org.tw/tlug.cle-devel
|
||||
locale.all.zh_CN.GB2312=GB2312
|
||||
# AIX
|
||||
@ -532,18 +524,10 @@ locale.all.ZH_CN=UTF-8
|
||||
locale.all.zh_CN.ugb=GB2312
|
||||
locale.all.zh_CN.GBK=gbk
|
||||
locale.all.zh_HK.big5=Big5
|
||||
locale.all.zh_HK.eucTW=x-euc-tw
|
||||
locale.all.zh_TW=x-euc-tw
|
||||
locale.all.zh_TW.IBM-eucTW=x-euc-tw
|
||||
locale.all.zh_TW.eucTW=x-euc-tw
|
||||
locale.all.zh_TW.eucTW@chuyin=x-euc-tw
|
||||
locale.all.zh_TW.eucTW@radical=x-euc-tw
|
||||
locale.all.zh_TW.eucTW@stroke=x-euc-tw
|
||||
locale.all.zh_TW.big5=Big5
|
||||
locale.all.zh_TW.big5@chuyin=Big5
|
||||
locale.all.zh_TW.big5@radical=Big5
|
||||
locale.all.zh_TW.big5@stroke=Big5
|
||||
locale.all.zh_TW.ucns=x-euc-tw
|
||||
# AIX
|
||||
locale.all.Zh_TW.big5=Big5
|
||||
# CLE 0.8
|
||||
|
@ -6,7 +6,7 @@
|
||||
# We use this to figure out the charset of file system, clipboard, etc
|
||||
#
|
||||
|
||||
acp.874=TIS-620
|
||||
acp.874=windows-874
|
||||
acp.932=Shift_JIS
|
||||
acp.936=gb18030
|
||||
acp.949=EUC-KR
|
||||
|
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsICharsetConverterManager.idl',
|
||||
'nsICurrentCharsetListener.idl',
|
||||
'nsIScriptableUConv.idl',
|
||||
'nsITextToSubURI.idl',
|
||||
|
@ -1,110 +0,0 @@
|
||||
/* -*- 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);
|
||||
};
|
@ -73,9 +73,8 @@ interface nsIScriptableUnicodeConverter : nsISupports
|
||||
/**
|
||||
* Internal use
|
||||
*
|
||||
* When this attribute is set, all charsets may be accessed.
|
||||
* When it is not set (the default), charsets with the isInternal flag
|
||||
* may not be accessed.
|
||||
* When this attribute is set, all charsets may be accessed but only
|
||||
* by Gecko-canonical name.
|
||||
*/
|
||||
attribute boolean isInternal;
|
||||
};
|
||||
|
@ -9,9 +9,6 @@
|
||||
#define NS_UNICODEDECODER_NAME "Charset Decoders"
|
||||
#define NS_UNICODEENCODER_NAME "Charset Encoders"
|
||||
|
||||
#define NS_DATA_BUNDLE_CATEGORY "uconv-charset-data"
|
||||
#define NS_TITLE_BUNDLE_CATEGORY "uconv-charset-titles"
|
||||
|
||||
#define NS_CONVERTER_REGISTRY_START \
|
||||
static const mozilla::Module::CategoryEntry kUConvCategories[] = {
|
||||
|
||||
|
@ -1,177 +0,0 @@
|
||||
# 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
|
@ -1,6 +0,0 @@
|
||||
# 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)
|
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsCharsetConverterManager.cpp',
|
||||
'nsConverterInputStream.cpp',
|
||||
'nsConverterOutputStream.cpp',
|
||||
'nsCP1252ToUnicode.cpp',
|
||||
@ -215,4 +214,3 @@ LOCAL_INCLUDES += [
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
@ -1,356 +0,0 @@
|
||||
/* -*- 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;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/* -*- 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"
|
||||
|
||||
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__
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
|
||||
#include "nsConverterInputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsReadLine.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include <algorithm>
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
#define CONVERTER_BUFFER_SIZE 8192
|
||||
|
||||
@ -23,22 +24,25 @@ nsConverterInputStream::Init(nsIInputStream* aStream,
|
||||
int32_t aBufferSize,
|
||||
char16_t aReplacementChar)
|
||||
{
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
||||
if (!aCharset)
|
||||
aCharset = "UTF-8";
|
||||
|
||||
nsresult rv;
|
||||
nsAutoCString label;
|
||||
if (!aCharset) {
|
||||
label.AssignLiteral("UTF-8");
|
||||
} else {
|
||||
label = aCharset;
|
||||
}
|
||||
|
||||
if (aBufferSize <=0) aBufferSize=CONVERTER_BUFFER_SIZE;
|
||||
|
||||
// get the decoder
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = ccm->GetUnicodeDecoder(aCharset ? aCharset : "ISO-8859-1", getter_AddRefs(mConverter));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsAutoCString encoding;
|
||||
if (label.EqualsLiteral("UTF-16")) {
|
||||
// Compat with old test cases. Unclear if any extensions really care.
|
||||
encoding.Assign(label);
|
||||
} else if (!EncodingUtils::FindEncodingForLabelNoReplacement(label,
|
||||
encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
mConverter = EncodingUtils::DecoderForEncoding(encoding);
|
||||
|
||||
// set up our buffers
|
||||
if (!mByteData.SetCapacity(aBufferSize) ||
|
||||
|
@ -6,10 +6,13 @@
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsConverterOutputStream.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsConverterOutputStream,
|
||||
nsIUnicharOutputStream,
|
||||
@ -28,17 +31,22 @@ nsConverterOutputStream::Init(nsIOutputStream* aOutStream,
|
||||
{
|
||||
NS_PRECONDITION(aOutStream, "Null output stream!");
|
||||
|
||||
if (!aCharset)
|
||||
aCharset = "UTF-8";
|
||||
nsAutoCString label;
|
||||
if (!aCharset) {
|
||||
label.AssignLiteral("UTF-8");
|
||||
} else {
|
||||
label = aCharset;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = ccm->GetUnicodeEncoder(aCharset, getter_AddRefs(mConverter));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsAutoCString encoding;
|
||||
if (label.EqualsLiteral("UTF-16")) {
|
||||
// Make sure to output a BOM when UTF-16 requested
|
||||
encoding.Assign(label);
|
||||
} else if (!EncodingUtils::FindEncodingForLabelNoReplacement(label,
|
||||
encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
mConverter = EncodingUtils::EncoderForEncoding(encoding);
|
||||
|
||||
mOutStream = aOutStream;
|
||||
|
||||
|
@ -4,13 +4,15 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIScriptableUConv.h"
|
||||
#include "nsScriptableUConv.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsCharsetAlias.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
|
||||
@ -253,44 +255,37 @@ nsScriptableUnicodeConverter::SetIsInternal(const bool aIsInternal)
|
||||
nsresult
|
||||
nsScriptableUnicodeConverter::InitConverter()
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
mEncoder = nullptr;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !ccm) {
|
||||
return rv;
|
||||
nsAutoCString encoding;
|
||||
if (mIsInternal) {
|
||||
encoding.Assign(mCharset);
|
||||
// Better have a valid encoding name at this point! Otherwise, we'll
|
||||
// crash with MOZ_ASSERT in debug builds. However, since this code
|
||||
// might be called by severely misguided extensions in opt builds, the
|
||||
// error condition is tested for below.
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(mCharset);
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(mCharset);
|
||||
if (!mEncoder || !mDecoder) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
|
||||
// get an unicode converter
|
||||
rv = ccm->GetUnicodeEncoder(mCharset.get(), getter_AddRefs(mEncoder));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
} else {
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(mCharset, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
|
||||
rv = mEncoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nullptr, (char16_t)'?');
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoCString charset;
|
||||
rv = mIsInternal ? nsCharsetAlias::GetPreferredInternal(mCharset, charset)
|
||||
: nsCharsetAlias::GetPreferred(mCharset, charset);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = ccm->GetUnicodeDecoderRaw(charset.get(), getter_AddRefs(mDecoder));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
mEncoder = EncodingUtils::EncoderForEncoding(encoding);
|
||||
mDecoder = EncodingUtils::DecoderForEncoding(encoding);
|
||||
}
|
||||
|
||||
// The UTF-8 decoder used to throw regardless of the error behavior.
|
||||
// Simulating the old behavior for compatibility with legacy callers
|
||||
// (including addons). If callers want a control over the behavior,
|
||||
// they should switch to TextDecoder.
|
||||
if (charset.EqualsLiteral("UTF-8")) {
|
||||
if (encoding.EqualsLiteral("UTF-8")) {
|
||||
mDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
|
||||
}
|
||||
|
||||
return rv ;
|
||||
return mEncoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace,
|
||||
nullptr,
|
||||
(char16_t)'?');
|
||||
}
|
||||
|
@ -8,6 +8,9 @@
|
||||
#define __nsScriptableUConv_h_
|
||||
|
||||
#include "nsIScriptableUConv.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
|
||||
class nsScriptableUnicodeConverter : public nsIScriptableUnicodeConverter
|
||||
{
|
||||
|
@ -4,14 +4,14 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "nsString.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsTextToSubURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
nsTextToSubURI::nsTextToSubURI()
|
||||
{
|
||||
@ -25,28 +25,30 @@ NS_IMPL_ISUPPORTS(nsTextToSubURI, nsITextToSubURI)
|
||||
NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
|
||||
const char *charset, const char16_t *text, char **_retval)
|
||||
{
|
||||
if(nullptr == _retval)
|
||||
if (!_retval) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*_retval = nullptr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get Charset, get the encoder.
|
||||
nsICharsetConverterManager *ccm;
|
||||
rv = CallGetService(kCharsetConverterManagerCID, &ccm);
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
nsIUnicodeEncoder *encoder;
|
||||
rv = ccm->GetUnicodeEncoder(charset, &encoder);
|
||||
NS_RELEASE(ccm);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!charset) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsDependentCString label(charset);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
nsCOMPtr<nsIUnicodeEncoder> encoder =
|
||||
EncodingUtils::EncoderForEncoding(encoding);
|
||||
rv = encoder->SetOutputErrorBehavior(nsIUnicodeEncoder::kOnError_Replace, nullptr, (char16_t)'?');
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv) ) {
|
||||
char buf[256];
|
||||
char *pBuf = buf;
|
||||
int32_t ulen = text ? NS_strlen(text) : 0;
|
||||
int32_t outlen = 0;
|
||||
if(NS_SUCCEEDED(rv = encoder->GetMaxLength(text, ulen, &outlen)))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv = encoder->GetMaxLength(text, ulen, &outlen))) {
|
||||
if (outlen >= 256) {
|
||||
pBuf = (char*)NS_Alloc(outlen+1);
|
||||
}
|
||||
@ -59,19 +61,19 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape(
|
||||
// put termination characters (e.g. ESC(B of ISO-2022-JP) if necessary
|
||||
int32_t finLen = bufLen - outlen;
|
||||
if (finLen > 0) {
|
||||
if (NS_SUCCEEDED(encoder->Finish((char *)(pBuf+outlen), &finLen)))
|
||||
if (NS_SUCCEEDED(encoder->Finish((char *)(pBuf+outlen), &finLen))) {
|
||||
outlen += finLen;
|
||||
}
|
||||
}
|
||||
pBuf[outlen] = '\0';
|
||||
*_retval = nsEscape(pBuf, url_XPAlphas);
|
||||
if(nullptr == *_retval)
|
||||
if (nullptr == *_retval) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if(pBuf != buf)
|
||||
NS_Free(pBuf);
|
||||
}
|
||||
NS_RELEASE(encoder);
|
||||
if (pBuf != buf) {
|
||||
NS_Free(pBuf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,6 +93,11 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
|
||||
*_retval = nullptr;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!charset) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
|
||||
// unescape the string, unescape changes the input
|
||||
char *unescaped = NS_strdup(text);
|
||||
if (nullptr == unescaped)
|
||||
@ -98,31 +105,28 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeAndConvert(
|
||||
unescaped = nsUnescape(unescaped);
|
||||
NS_ASSERTION(unescaped, "nsUnescape returned null");
|
||||
|
||||
// Convert from the charset to unicode
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(kCharsetConverterManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIUnicodeDecoder *decoder;
|
||||
rv = ccm->GetUnicodeDecoder(charset, &decoder);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsDependentCString label(charset);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
nsCOMPtr<nsIUnicodeDecoder> decoder =
|
||||
EncodingUtils::DecoderForEncoding(encoding);
|
||||
char16_t *pBuf = nullptr;
|
||||
int32_t len = strlen(unescaped);
|
||||
int32_t outlen = 0;
|
||||
if (NS_SUCCEEDED(rv = decoder->GetMaxLength(unescaped, len, &outlen))) {
|
||||
pBuf = (char16_t *) NS_Alloc((outlen+1)*sizeof(char16_t));
|
||||
if (nullptr == pBuf)
|
||||
if (nullptr == pBuf) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
else {
|
||||
} else {
|
||||
if (NS_SUCCEEDED(rv = decoder->Convert(unescaped, &len, pBuf, &outlen))) {
|
||||
pBuf[outlen] = 0;
|
||||
*_retval = pBuf;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
NS_Free(pBuf);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(decoder);
|
||||
}
|
||||
}
|
||||
NS_Free(unescaped);
|
||||
|
||||
@ -164,14 +168,13 @@ nsresult nsTextToSubURI::convertURItoUnicode(const nsAFlatCString &aCharset,
|
||||
// empty charset could indicate UTF-8, but aURI turns out not to be UTF-8.
|
||||
NS_ENSURE_FALSE(aCharset.IsEmpty(), NS_ERROR_INVALID_ARG);
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> charsetConverterManager;
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(aCharset, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder =
|
||||
EncodingUtils::DecoderForEncoding(encoding);
|
||||
|
||||
charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
|
||||
rv = charsetConverterManager->GetUnicodeDecoder(aCharset.get(),
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
unicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define nsTextToSubURI_h__
|
||||
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsString.h"
|
||||
|
||||
//==============================================================
|
||||
class nsTextToSubURI: public nsITextToSubURI {
|
||||
|
@ -3,13 +3,11 @@
|
||||
* 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/ModuleUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsEncoderDecoderUtils.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncoder.h"
|
||||
|
||||
#include "nsUConvCID.h"
|
||||
#include "nsCharsetConverterManager.h"
|
||||
#include "nsTextToSubURI.h"
|
||||
#include "nsUTF8ConverterService.h"
|
||||
#include "nsConverterInputStream.h"
|
||||
@ -297,9 +295,6 @@ NS_UCONV_REG_UNREG("HZ-GB-2312", NS_HZTOUNICODE_CID, NS_UNICODETOHZ_CID)
|
||||
NS_UCONV_REG_UNREG("gb18030", NS_GB18030TOUNICODE_CID, NS_UNICODETOGB18030_CID)
|
||||
NS_UCONV_REG_UNREG_DECODER("ISO-2022-CN", NS_ISO2022CNTOUNICODE_CID)
|
||||
|
||||
{ NS_TITLE_BUNDLE_CATEGORY, "chrome://global/locale/charsetTitles.properties", "" },
|
||||
{ NS_DATA_BUNDLE_CATEGORY, "resource://gre-resources/charsetData.properties", "" },
|
||||
|
||||
NS_CONVERTER_REGISTRY_END
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToUTF8)
|
||||
@ -454,14 +449,12 @@ const uint16_t g_ufJohabJamoMapping[] ={
|
||||
#include "johabjamo.uf"
|
||||
};
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetConverterManager)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextToSubURI)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUTF8ConverterService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConverterInputStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConverterOutputStream)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableUnicodeConverter)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_TEXTTOSUBURI_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CONVERTERINPUTSTREAM_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_CONVERTEROUTPUTSTREAM_CID);
|
||||
@ -628,7 +621,6 @@ NS_DEFINE_NAMED_CID(NS_UNICODETOGB18030_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ISO2022CNTOUNICODE_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kUConvCIDs[] = {
|
||||
{ &kNS_ICHARSETCONVERTERMANAGER_CID, false, nullptr, nsCharsetConverterManagerConstructor },
|
||||
{ &kNS_TEXTTOSUBURI_CID, false, nullptr, nsTextToSubURIConstructor },
|
||||
{ &kNS_CONVERTERINPUTSTREAM_CID, false, nullptr, nsConverterInputStreamConstructor },
|
||||
{ &kNS_CONVERTEROUTPUTSTREAM_CID, false, nullptr, nsConverterOutputStreamConstructor },
|
||||
@ -797,7 +789,6 @@ static const mozilla::Module::CIDEntry kUConvCIDs[] = {
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kUConvContracts[] = {
|
||||
{ NS_CHARSETCONVERTERMANAGER_CONTRACTID, &kNS_ICHARSETCONVERTERMANAGER_CID },
|
||||
{ NS_ITEXTTOSUBURI_CONTRACTID, &kNS_TEXTTOSUBURI_CID },
|
||||
{ NS_CONVERTERINPUTSTREAM_CONTRACTID, &kNS_CONVERTERINPUTSTREAM_CID },
|
||||
{ "@mozilla.org/intl/converter-output-stream;1", &kNS_CONVERTEROUTPUTSTREAM_CID },
|
||||
|
@ -5,11 +5,13 @@
|
||||
* 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 "nsString.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsUTF8ConverterService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsUTF8ConverterService, nsIUTF8ConverterService)
|
||||
|
||||
@ -21,15 +23,13 @@ ToUTF8(const nsACString &aString, const char *aCharset,
|
||||
if (!aCharset || !*aCharset)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm;
|
||||
|
||||
ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder;
|
||||
rv = ccm->GetUnicodeDecoder(aCharset,
|
||||
getter_AddRefs(unicodeDecoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsDependentCString label(aCharset);
|
||||
nsAutoCString encoding;
|
||||
if (!EncodingUtils::FindEncodingForLabelNoReplacement(label, encoding)) {
|
||||
return NS_ERROR_UCONV_NOCONV;
|
||||
}
|
||||
nsCOMPtr<nsIUnicodeDecoder> unicodeDecoder =
|
||||
EncodingUtils::DecoderForEncoding(encoding);
|
||||
|
||||
if (!aAllowSubstitution)
|
||||
unicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
|
||||
|
@ -25,29 +25,56 @@ const testContent = "<pre id='testPara'>" + inString;
|
||||
|
||||
const Ci = SpecialPowers.Ci;
|
||||
const Cc = SpecialPowers.Cc;
|
||||
var ccManager = Cc["@mozilla.org/charset-converter-manager;1"].getService(Ci.nsICharsetConverterManager);
|
||||
|
||||
var decoderList = ccManager.getDecoderList();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
while (decoderList.hasMore()) {
|
||||
var decoder = decoderList.getNext();
|
||||
var decoders = [
|
||||
"Big5",
|
||||
"Big5-HKSCS",
|
||||
"EUC-JP",
|
||||
"EUC-KR",
|
||||
"gb18030",
|
||||
"IBM866",
|
||||
"ISO-2022-JP",
|
||||
"ISO-8859-3",
|
||||
"ISO-8859-4",
|
||||
"ISO-8859-5",
|
||||
"ISO-8859-6",
|
||||
"ISO-8859-7",
|
||||
"ISO-8859-8",
|
||||
"ISO-8859-8-I",
|
||||
"ISO-8859-10",
|
||||
"ISO-8859-13",
|
||||
"ISO-8859-14",
|
||||
"ISO-8859-15",
|
||||
"ISO-8859-16",
|
||||
"ISO-8859-2",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"Shift_JIS",
|
||||
"windows-1250",
|
||||
"windows-1251",
|
||||
"windows-1252",
|
||||
"windows-1253",
|
||||
"windows-1254",
|
||||
"windows-1255",
|
||||
"windows-1256",
|
||||
"windows-1257",
|
||||
"windows-1258",
|
||||
"windows-874",
|
||||
"x-mac-cyrillic",
|
||||
"UTF-8"
|
||||
];
|
||||
|
||||
// Skip UTF-16 variants. (Other non-ASCII compatible encodings will be
|
||||
// ignored anyway because of bug 601429
|
||||
if (decoder.substring(0, 6) == "UTF-16" ||
|
||||
decoder == "replacement" ||
|
||||
decoder == "ISO-2022-KR" ||
|
||||
decoder == "ISO-2022-CN")
|
||||
continue;
|
||||
|
||||
data = encodeURI(testContent);
|
||||
var decoder;
|
||||
for (var i = 0; i < decoders.length; i++) {
|
||||
var decoder = decoders[i];
|
||||
var data = encodeURI(testContent);
|
||||
var dataURI = "data:text/html;charset=" + decoder + "," + data;
|
||||
|
||||
var testFrame = document.createElement("iframe");
|
||||
frameID = decoder;
|
||||
testFrame.setAttribute("id", frameID);
|
||||
var testFrameObj = document.body.appendChild(testFrame);
|
||||
if (decoderList.hasMore())
|
||||
if (i < decoders.length)
|
||||
testFrameObj.setAttribute("onload", "testDecoding('" + decoder + "')");
|
||||
else
|
||||
testFrameObj.setAttribute("onload", "lastTest('" + decoder + "')");
|
||||
|
@ -20,7 +20,7 @@ const expectedMonospace9 = "Hello9Monospace9";
|
||||
const EntityAfterCharsetConv = 512;
|
||||
const transliterate = 8;
|
||||
|
||||
const charset = "ISO-8859-1";
|
||||
const charset = "ISO-8859-2";
|
||||
|
||||
function run_test() {
|
||||
var SaveAsCharset =
|
||||
|
@ -1,60 +0,0 @@
|
||||
const charset = "x-johab";
|
||||
|
||||
function dumpStrings(inString, outString) {
|
||||
var dispIn = "";
|
||||
var dispOut = "";
|
||||
var i;
|
||||
for (i = 0; i < inString.length; ++i) {
|
||||
dispIn += " x" + inString.charCodeAt(i).toString(16);
|
||||
}
|
||||
if (outString.length == 0) {
|
||||
dispOut = "<empty>";
|
||||
} else {
|
||||
for (i = 0; i < outString.length; ++i) {
|
||||
dispOut += " x" + outString.charCodeAt(i).toString(16);
|
||||
}
|
||||
}
|
||||
dump("\"" + dispIn + "\" ==> \"" + dispOut + "\"\n");
|
||||
}
|
||||
|
||||
function error(inString, outString, msg){
|
||||
dumpStrings(inString, outString);
|
||||
do_throw("security risk: " + msg);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
var ScriptableUnicodeConverter =
|
||||
Components.Constructor("@mozilla.org/intl/scriptableunicodeconverter",
|
||||
"nsIScriptableUnicodeConverter");
|
||||
|
||||
var converter = new ScriptableUnicodeConverter();
|
||||
converter.charset = charset;
|
||||
|
||||
var leadByte, trailByte;
|
||||
var inString;
|
||||
for (leadByte = 1; leadByte < 0x100; ++leadByte) {
|
||||
for (trailByte = 1; trailByte < 0x100; ++trailByte) {
|
||||
inString = String.fromCharCode(leadByte, trailByte, 65);
|
||||
var outString = converter.ConvertToUnicode(inString) + converter.Finish();
|
||||
switch (outString.length) {
|
||||
case 1:
|
||||
error(inString, outString, "2 byte sequence eaten");
|
||||
break;
|
||||
case 2:
|
||||
if (outString.charCodeAt(0) < 0x80 &&
|
||||
outString.charCodeAt(1) < 0x80) {
|
||||
error(inString, outString, "2 byte sequence converted to 1 ASCII");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (outString != inString &&
|
||||
outString.charCodeAt(0) < 0x80 &&
|
||||
outString.charCodeAt(1) < 0x80) {
|
||||
error(inString, outString,
|
||||
"2 byte sequence converted to 2 ASCII");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// Make sure that we can resolve the ascii charset alias to us-ascii
|
||||
// (bug 383018)
|
||||
|
||||
function run_test() {
|
||||
var ccm = Components.classes["@mozilla.org/charset-converter-manager;1"];
|
||||
var ccms = ccm.getService(Components.interfaces.nsICharsetConverterManager);
|
||||
|
||||
var alias = ccms.getCharsetAlias("ascii");
|
||||
// ascii should be an alias for us-ascii
|
||||
do_check_eq(alias, "us-ascii");
|
||||
}
|
@ -6,22 +6,50 @@ const expectedString = "Hello\nWorld";
|
||||
|
||||
function run_test() {
|
||||
var failures = false;
|
||||
var ccManager = Cc["@mozilla.org/charset-converter-manager;1"]
|
||||
.getService(Ci.nsICharsetConverterManager);
|
||||
var encodingConverter = CreateScriptableConverter();
|
||||
|
||||
var charsetList = ccManager.getDecoderList();
|
||||
var decoders = [
|
||||
"Big5",
|
||||
"Big5-HKSCS",
|
||||
"EUC-JP",
|
||||
"EUC-KR",
|
||||
"gb18030",
|
||||
"IBM866",
|
||||
"ISO-2022-JP",
|
||||
"ISO-8859-3",
|
||||
"ISO-8859-4",
|
||||
"ISO-8859-5",
|
||||
"ISO-8859-6",
|
||||
"ISO-8859-7",
|
||||
"ISO-8859-8",
|
||||
"ISO-8859-8-I",
|
||||
"ISO-8859-10",
|
||||
"ISO-8859-13",
|
||||
"ISO-8859-14",
|
||||
"ISO-8859-15",
|
||||
"ISO-8859-16",
|
||||
"ISO-8859-2",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"Shift_JIS",
|
||||
"windows-1250",
|
||||
"windows-1251",
|
||||
"windows-1252",
|
||||
"windows-1253",
|
||||
"windows-1254",
|
||||
"windows-1255",
|
||||
"windows-1256",
|
||||
"windows-1257",
|
||||
"windows-1258",
|
||||
"windows-874",
|
||||
"x-mac-cyrillic",
|
||||
"UTF-8"
|
||||
];
|
||||
|
||||
var counter = 0;
|
||||
while (charsetList.hasMore()) {
|
||||
while (counter < decoders.length) {
|
||||
++counter;
|
||||
var charset = charsetList.getNext();
|
||||
var charset = decoders[counter];
|
||||
|
||||
// exclude known non-ASCII compatible charsets
|
||||
if (charset.substr(0, "UTF-16".length) == "UTF-16" ||
|
||||
charset == "x-imap4-modified-utf7") {
|
||||
dump("skipping " + counter + " " + charset + "\n");
|
||||
continue;
|
||||
}
|
||||
dump("testing " + counter + " " + charset + "\n");
|
||||
|
||||
try {
|
||||
|
@ -1,21 +0,0 @@
|
||||
function run_test()
|
||||
{
|
||||
var failures = false;
|
||||
var ccManager =
|
||||
Components.classes["@mozilla.org/charset-converter-manager;1"]
|
||||
.getService(Components.interfaces.nsICharsetConverterManager);
|
||||
|
||||
var decoderList = ccManager.getDecoderList();
|
||||
while (decoderList.hasMore()) {
|
||||
var decoder = decoderList.getNext();
|
||||
try {
|
||||
var langGroup = ccManager.getCharsetLangGroupRaw(decoder);
|
||||
} catch(e) {
|
||||
dump("no langGroup for " + decoder + "\n");
|
||||
failures = true;
|
||||
}
|
||||
}
|
||||
if (failures) {
|
||||
do_throw("missing langGroups");
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/* Tests conversion from ISO-2022-KR to Unicode (bug 449578)
|
||||
*/
|
||||
|
||||
// designator sequence at beginning of line - legal
|
||||
const in1 = "%1B$)C%0E0!3*4Y6s%0F 1234";
|
||||
// empty non-ASCII sequence -- illegal
|
||||
const in2 = "%1B$)Cab%0E%0Fcd";
|
||||
// designator sequence not at beginning of line - illegal
|
||||
const in3 = "abc %1B$)C%0E0!3*4Y6s%0F 1234";
|
||||
|
||||
const expected1 = "\uAC00\uB098\uB2E4\uB77C 1234";
|
||||
const expected2 = "ab\uFFFD\cd";
|
||||
const expected3 = "abc \u001B$)C\uAC00\uB098\uB2E4\uB77C 1234";
|
||||
|
||||
function testCase(inStr, expected)
|
||||
{
|
||||
var dataURI = "data:text/plain;charset=ISO-2022-KR," + inStr;
|
||||
|
||||
var IOService = Components.Constructor("@mozilla.org/network/io-service;1",
|
||||
"nsIIOService");
|
||||
var ConverterInputStream =
|
||||
Components.Constructor("@mozilla.org/intl/converter-input-stream;1",
|
||||
"nsIConverterInputStream",
|
||||
"init");
|
||||
|
||||
var ios = new IOService();
|
||||
var channel = ios.newChannel(dataURI, "", null);
|
||||
var testInputStream = channel.open();
|
||||
var testConverter = new ConverterInputStream(testInputStream,
|
||||
"ISO-2022-KR",
|
||||
8192,
|
||||
0xFFFD);
|
||||
|
||||
if (!(testConverter instanceof
|
||||
Components.interfaces.nsIUnicharLineInputStream))
|
||||
throw "not line input stream";
|
||||
|
||||
var outStr = "";
|
||||
var more;
|
||||
do {
|
||||
// read the line and check for eof
|
||||
var line = {};
|
||||
more = testConverter.readLine(line);
|
||||
outStr += line.value;
|
||||
} while (more);
|
||||
|
||||
do_check_eq(outStr, expected);
|
||||
}
|
||||
|
||||
function run_test()
|
||||
{
|
||||
testCase(in1, expected1);
|
||||
testCase(in2, expected2);
|
||||
testCase(in3, expected3);
|
||||
}
|
@ -4,15 +4,49 @@ load('CharsetConversionTests.js');
|
||||
|
||||
function run_test() {
|
||||
var failures = false;
|
||||
var ccManager = Cc["@mozilla.org/charset-converter-manager;1"]
|
||||
.getService(Ci.nsICharsetConverterManager);
|
||||
var decodingConverter = CreateScriptableConverter();
|
||||
|
||||
var charsetList = ccManager.getDecoderList();
|
||||
var decoders = [
|
||||
"Big5",
|
||||
"Big5-HKSCS",
|
||||
"EUC-JP",
|
||||
"EUC-KR",
|
||||
"gb18030",
|
||||
"IBM866",
|
||||
"ISO-2022-JP",
|
||||
"ISO-8859-3",
|
||||
"ISO-8859-4",
|
||||
"ISO-8859-5",
|
||||
"ISO-8859-6",
|
||||
"ISO-8859-7",
|
||||
"ISO-8859-8",
|
||||
"ISO-8859-8-I",
|
||||
"ISO-8859-10",
|
||||
"ISO-8859-13",
|
||||
"ISO-8859-14",
|
||||
"ISO-8859-15",
|
||||
"ISO-8859-16",
|
||||
"ISO-8859-2",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"Shift_JIS",
|
||||
"windows-1250",
|
||||
"windows-1251",
|
||||
"windows-1252",
|
||||
"windows-1253",
|
||||
"windows-1254",
|
||||
"windows-1255",
|
||||
"windows-1256",
|
||||
"windows-1257",
|
||||
"windows-1258",
|
||||
"windows-874",
|
||||
"x-mac-cyrillic",
|
||||
"UTF-8"
|
||||
];
|
||||
|
||||
var counter = 0;
|
||||
while (charsetList.hasMore()) {
|
||||
while (counter < decoders.length) {
|
||||
++counter;
|
||||
var charset = charsetList.getNext();
|
||||
var charset = decoders[counter];
|
||||
dump("testing " + counter + " " + charset + "\n");
|
||||
|
||||
try {
|
||||
|
@ -1,19 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
function run_test() {
|
||||
let svc = Components.classes["@mozilla.org/charset-converter-manager;1"]
|
||||
.getService(Components.interfaces.nsICharsetConverterManager);
|
||||
|
||||
// Ensure normal calls to getCharsetAlias do work.
|
||||
do_check_eq(svc.getCharsetAlias("Windows-1255"), "windows-1255");
|
||||
|
||||
try {
|
||||
svc.getCharsetAlias("no such thing");
|
||||
do_throw("Calling getCharsetAlias with invalid value should throw.");
|
||||
}
|
||||
catch (ex) {
|
||||
// The exception is expected.
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
// 2-byte charsets:
|
||||
const charsets = [ "Big5", "EUC-KR", "x-euc-tw", "x-johab" ]
|
||||
const charsets = [ "Big5", "EUC-KR" ]
|
||||
const ScriptableUnicodeConverter =
|
||||
Components.Constructor("@mozilla.org/intl/scriptableunicodeconverter",
|
||||
"nsIScriptableUnicodeConverter");
|
||||
|
@ -6,7 +6,7 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0402\u0403\u201a\u0453\u201e\u2026\u2020\u2021\u20ac\u2030\u0409\u2039\u040a\u040c\u040b\u040f\u0452\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u2122\u0459\u203a\u045a\u045c\u045b\u045f\u00a0\u040e\u045e\u0408\u00a4\u0490\u00a6\u00a7\u0401\u00a9\u0404\u00ab\u00ac\u00ad\u00ae\u0407\u00b0\u00b1\u0406\u0456\u0491\u00b5\u00b6\u00b7\u0451\u2116\u0454\u00bb\u0458\u0405\u0455\u0457\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e\u044f";
|
||||
|
||||
const aliases = [ "windows-1251", "x-cp1251", "cp1251", "ansi-1251" ];
|
||||
const aliases = [ "windows-1251", "x-cp1251", "cp1251" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u00c1\u00c2\u00c0\u00a9\u2563\u2551\u2557\u255d\u00a2\u00a5\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u00e3\u00c3\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u00a4\u00f0\u00d0\u00ca\u00cb\u00c8\u20ac\u00cd\u00ce\u00cf\u2518\u250c\u2588\u2584\u00a6\u00cc\u2580\u00d3\u00df\u00d4\u00d2\u00f5\u00d5\u00b5\u00fe\u00de\u00da\u00db\u00d9\u00fd\u00dd\u00af\u00b4\u00ad\u00b1\u2017\u00be\u00b6\u00a7\u00f7\u00b8\u00b0\u00a8\u00b7\u00b9\u00b3\u00b2\u25a0\u00a0";
|
||||
|
||||
const aliases = [ "IBM850", "ibm850", "cp850", "850", "csibm850" ];
|
||||
//const aliases = [ "IBM850", "ibm850", "cp850", "850", "csibm850" ];
|
||||
const aliases = [ "IBM850" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u00c7\u00fc\u00e9\u00e2\u00e4\u016f\u0107\u00e7\u0142\u00eb\u0150\u0151\u00ee\u0179\u00c4\u0106\u00c9\u0139\u013a\u00f4\u00f6\u013d\u013e\u015a\u015b\u00d6\u00dc\u0164\u0165\u0141\u00d7\u010d\u00e1\u00ed\u00f3\u00fa\u0104\u0105\u017d\u017e\u0118\u0119\u20ac\u017a\u010c\u015f\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u00c1\u00c2\u011a\u015e\u2563\u2551\u2557\u255d\u017b\u017c\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u0102\u0103\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u00a4\u0111\u0110\u010e\u00cb\u010f\u0147\u00cd\u00ce\u011b\u2518\u250c\u2588\u2584\u0162\u016e\u2580\u00d3\u00df\u00d4\u0143\u0144\u0148\u0160\u0161\u0154\u00da\u0155\u0170\u00fd\u00dd\u0163\u00b4\u00ad\u02dd\u02db\u02c7\u02d8\u00a7\u00f7\u00b8\u00b0\u00a8\u02d9\u0171\u0158\u0159\u25a0\u00a0";
|
||||
|
||||
const aliases = [ "IBM852", "ibm852", "cp852", "852", "csibm852" ];
|
||||
//const aliases = [ "IBM852", "ibm852", "cp852", "852", "csibm852" ];
|
||||
const aliases = [ "IBM852" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408\u0459\u0409\u045a\u040a\u045b\u040b\u045c\u040c\u045e\u040e\u045f\u040f\u044e\u042e\u044a\u042a\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414\u0435\u0415\u0444\u0424\u0433\u0413\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438\u0418\u2563\u2551\u2557\u255d\u0439\u0419\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u043a\u041a\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u00a4\u043b\u041b\u043c\u041c\u043d\u041d\u043e\u041e\u043f\u2518\u250c\u2588\u2584\u041f\u044f\u2580\u042f\u0440\u0420\u0441\u0421\u0442\u0422\u0443\u0423\u0436\u0416\u0432\u0412\u044c\u042c\u2116\u00ad\u044b\u042b\u0437\u0417\u0448\u0428\u044d\u042d\u0449\u0429\u0447\u0427\u00a7\u25a0\u00a0";
|
||||
|
||||
const aliases = [ "IBM855", "ibm855", "cp855", "855", "csibm855" ];
|
||||
//const aliases = [ "IBM855", "ibm855", "cp855", "855", "csibm855" ];
|
||||
const aliases = [ "IBM855" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u0131\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u0130\u00d6\u00dc\u00f8\u00a3\u00d8\u015e\u015f\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u011e\u011f\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u00c1\u00c2\u00c0\u00a9\u2563\u2551\u2557\u255d\u00a2\u00a5\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u00e3\u00c3\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u00a4\u00ba\u00aa\u00ca\u00cb\u00c8\u20ac\u00cd\u00ce\u00cf\u2518\u250c\u2588\u2584\u00a6\u00cc\u2580\u00d3\u00df\u00d4\u00d2\u00f5\u00d5\u00b5\u00d7\u00da\u00db\u00d9\u00ec\u00ff\u00af\u00b4\u00ad\u00b1\u00be\u00b6\u00a7\u00f7\u00b8\u00b0\u00a8\u00b7\u00b9\u00b3\u00b2\u25a0\u00a0";
|
||||
|
||||
const aliases = [ "IBM857", "ibm857", "cp857", "857", "csibm857" ];
|
||||
//const aliases = [ "IBM857", "ibm857", "cp857", "857", "csibm857" ];
|
||||
const aliases = [ "IBM857" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u05d0\u05d1\u05d2\u05d3\u05d4\u05d5\u05d6\u05d7\u05d8\u05d9\u05da\u05db\u05dc\u05dd\u05de\u05df\u05e0\u05e1\u05e2\u05e3\u05e4\u05e5\u05e6\u05e7\u05e8\u05e9\u05ea\u00a2\u00a3\u00a5\u20aa\u200e\u200f\u202a\u202b\u202d\u202c\u202e\u2310\u00ac\u00bd\u00bc\u20ac\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u00df\u0393\u03c0\u03a3\u03c3\u00b5\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u03c6\u03b5\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u00a0";
|
||||
|
||||
const aliases = [ "IBM862", "ibm862", "cp862", "862", "csibm862" ];
|
||||
//const aliases = [ "IBM862", "ibm862", "cp862", "862", "csibm862" ];
|
||||
const aliases = [ "IBM862" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$\u066a&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u00b0\u00b7\u2219\u221a\u2592\u2500\u2502\u253c\u2524\u252c\u251c\u2534\u2510\u250c\u2514\u2518\u03b2\u221e\u03c6\u00b1\u00bd\u00bc\u2248\u00ab\u00bb\ufef7\ufef8\ufefb\ufefc\u00a0\u00ad\ufe82\u00a3\u00a4\ufe84\u20ac\ufe8e\ufe8f\ufe95\ufe99\u060c\ufe9d\ufea1\ufea5\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\ufed1\u061b\ufeb1\ufeb5\ufeb9\u061f\u00a2\ufe80\ufe81\ufe83\ufe85\ufeca\ufe8b\ufe8d\ufe91\ufe93\ufe97\ufe9b\ufe9f\ufea3\ufea7\ufea9\ufeab\ufead\ufeaf\ufeb3\ufeb7\ufebb\ufebf\ufec1\ufec5\ufecb\ufecf\u00a6\u00ac\u00f7\u00d7\ufec9\u0640\ufed3\ufed7\ufedb\ufedf\ufee3\ufee7\ufeeb\ufeed\ufeef\ufef3\ufebd\ufecc\ufece\ufecd\ufee1\ufe7d\u0651\ufee5\ufee9\ufeec\ufef0\ufef2\ufed0\ufed5\ufef5\ufef6\ufedd\ufed9\ufef1\u25a0";
|
||||
|
||||
const aliases = [ "IBM864", "ibm864", "cp864", "864", "csibm864", "ibm-864" ];
|
||||
// const aliases = [ "IBM864", "ibm864", "cp864", "864", "csibm864", "ibm-864" ];
|
||||
// Aliases no longer supported for internal encodings in the test harness
|
||||
const aliases = [ "IBM864" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliasesInternal();
|
||||
|
@ -6,7 +6,7 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u20ac\u2026\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u00a0\u0e01\u0e02\u0e03\u0e04\u0e05\u0e06\u0e07\u0e08\u0e09\u0e0a\u0e0b\u0e0c\u0e0d\u0e0e\u0e0f\u0e10\u0e11\u0e12\u0e13\u0e14\u0e15\u0e16\u0e17\u0e18\u0e19\u0e1a\u0e1b\u0e1c\u0e1d\u0e1e\u0e1f\u0e20\u0e21\u0e22\u0e23\u0e24\u0e25\u0e26\u0e27\u0e28\u0e29\u0e2a\u0e2b\u0e2c\u0e2d\u0e2e\u0e2f\u0e30\u0e31\u0e32\u0e33\u0e34\u0e35\u0e36\u0e37\u0e38\u0e39\u0e3a\u0e3f\u0e40\u0e41\u0e42\u0e43\u0e44\u0e45\u0e46\u0e47\u0e48\u0e49\u0e4a\u0e4b\u0e4c\u0e4d\u0e4e\u0e4f\u0e50\u0e51\u0e52\u0e53\u0e54\u0e55\u0e56\u0e57\u0e58\u0e59\u0e5a\u0e5b";
|
||||
|
||||
const aliases = [ "windows-874", "ibm874", "dos-874" ];
|
||||
const aliases = [ "windows-874", "dos-874" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
|
@ -4,7 +4,7 @@
|
||||
load('CharsetConversionTests.js');
|
||||
load('hangulTestStrings.js');
|
||||
|
||||
const aliases = [ "euc-kr", "EUC-KR", "iso-ir-149", "ks_c_5601-1989", "ksc_5601", "ksc5601", "korean", "csksc56011987", "5601", "windows-949", "ks_c_5601-1987", "cseuckr"];
|
||||
const aliases = [ "euc-kr", "EUC-KR", "iso-ir-149", "ks_c_5601-1989", "ksc_5601", "ksc5601", "korean", "csksc56011987", "windows-949", "ks_c_5601-1987", "cseuckr"];
|
||||
|
||||
function to8byteHangul(byte3, byte5, byte7)
|
||||
{
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = ["armscii-8"];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = "\u00da\u1ee4\u1eea\u1eec\u1eee\u1ee8\u1ef0\u1ef2\u1ef6\u
|
||||
const aliases = [ "x-viet-tcvn5712" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
|
||||
const expectedString = "\u1eb2\u1eb4\u1eaa\u1ef6\u1ef8\u1ef4 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u1ea0\u1eae\u1eb0\u1eb6\u1ea4\u1ea6\u1ea8\u1eac\u1ebc\u1eb8\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1ee2\u1eda\u1edc\u1ede\u1eca\u1ece\u1ecc\u1ec8\u1ee6\u0168\u1ee4\u1ef2\u00d5\u1eaf\u1eb1\u1eb7\u1ea5\u1ea7\u1ea9\u1ead\u1ebd\u1eb9\u1ebf\u1ec1\u1ec3\u1ec5\u1ec7\u1ed1\u1ed3\u1ed5\u1ed7\u1ee0\u01a0\u1ed9\u1edd\u1edf\u1ecb\u1ef0\u1ee8\u1eea\u1eec\u01a1\u1edb\u01af\u00c0\u00c1\u00c2\u00c3\u1ea2\u0102\u1eb3\u1eb5\u00c8\u00c9\u00ca\u1eba\u00cc\u00cd\u0128\u1ef3\u0110\u1ee9\u00d2\u00d3\u00d4\u1ea1\u1ef7\u1eeb\u1eed\u00d9\u00da\u1ef9\u1ef5\u00dd\u1ee1\u01b0\u00e0\u00e1\u00e2\u00e3\u1ea3\u0103\u1eef\u1eab\u00e8\u00e9\u00ea\u1ebb\u00ec\u00ed\u0129\u1ec9\u0111\u1ef1\u00f2\u00f3\u00f4\u00f5\u1ecf\u1ecd\u1ee5\u00f9\u00fa\u0169\u1ee7\u00fd\u1ee3\u1eee";
|
||||
|
||||
const aliases = [ "VISCII", "viscii", "csviscii" ];
|
||||
//const aliases = [ "VISCII", "viscii", "csviscii" ];
|
||||
const aliases = [ "VISCII" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = "\u1ea0\u1eac\u1eb6\u1eb8\u1ec6\u1eca\u1ecc\u1ed8\u1ee2\u
|
||||
const aliases = [ "x-viet-vps" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-ce" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-croatian" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-cyrillic" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-devanagari" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-greek" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-gujarati" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-gurmukhi" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-icelandic" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-romanian" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-turkish" ];
|
||||
|
||||
function run_test() {
|
||||
testDecodeAliases();
|
||||
testDecodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "windows-1251", "x-cp1251", "cp1251", "ansi-1251" ];
|
||||
const aliases = [ "windows-1251", "x-cp1251", "cp1251" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "IBM850", "ibm850", "cp850", "850", "csibm850" ];
|
||||
//const aliases = [ "IBM850", "ibm850", "cp850", "850", "csibm850" ];
|
||||
const aliases = [ "IBM850" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "IBM852", "ibm852", "cp852", "852", "csibm852" ];
|
||||
//const aliases = [ "IBM852", "ibm852", "cp852", "852", "csibm852" ];
|
||||
const aliases = [ "IBM852" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "IBM855", "ibm855", "cp855", "855", "csibm855" ];
|
||||
//const aliases = [ "IBM855", "ibm855", "cp855", "855", "csibm855" ];
|
||||
const aliases = [ "IBM855" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "IBM857", "ibm857", "cp857", "857", "csibm857" ];
|
||||
//const aliases = [ "IBM857", "ibm857", "cp857", "857", "csibm857" ];
|
||||
const aliases = [ "IBM857" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "IBM862", "ibm862", "cp862", "862", "csibm862" ];
|
||||
//const aliases = [ "IBM862", "ibm862", "cp862", "862", "csibm862" ];
|
||||
const aliases = [ "IBM862" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ const inString = " !\"#$\u066a&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVW
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9d\x9e\xa0\xa1\xa2\xa3\xa4\xa5\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe";
|
||||
|
||||
const aliases = [ "IBM864", "ibm864", "cp864", "864", "csibm864", "ibm-864" ];
|
||||
//const aliases = [ "IBM864", "ibm864", "cp864", "864", "csibm864", "ibm-864" ];
|
||||
const aliases = [ "IBM864" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliasesInternal();
|
||||
|
@ -6,7 +6,7 @@ const inString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x85\x91\x92\x93\x94\x95\x96\x97\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb";
|
||||
|
||||
const aliases = [ "windows-874", "ibm874", "dos-874" ];
|
||||
const aliases = [ "windows-874", "dos-874" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = ["armscii-8"];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ
|
||||
const aliases = [ "x-viet-tcvn5712" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ const inString = "\u1eb2\u1eb4\u1eaa\u1ef6\u1ef8\u1ef4 !\"#$%&'()*+,-./012345678
|
||||
|
||||
const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const aliases = [ "VISCII", "viscii", "csviscii" ];
|
||||
//const aliases = [ "VISCII", "viscii", "csviscii" ];
|
||||
const aliases = [ "VISCII" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGH
|
||||
const aliases = [ "x-viet-vps" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-ce" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-croatian" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-devanagari" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-greek" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ const expectedString = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV
|
||||
const aliases = [ "x-mac-gujarati" ];
|
||||
|
||||
function run_test() {
|
||||
testEncodeAliases();
|
||||
testEncodeAliasesInternal();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user