mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-07 15:12:28 +00:00
Bug 564774 - nsMacCharset.cpp looks obsolete. r=smontagu
This commit is contained in:
parent
79a3953c0d
commit
5f5d1cd184
@ -58,12 +58,3 @@ CPPSRCS = \
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/..
|
||||
|
||||
nsMacCharset.$(OBJ_SUFFIX): maccharset.properties.h
|
||||
|
||||
maccharset.properties.h: $(srcdir)/../props2arrays.py maccharset.properties
|
||||
$(PYTHON) $^ $@
|
||||
|
||||
GARBAGE += \
|
||||
maccharset.properties.h \
|
||||
$(NULL)
|
||||
|
@ -1,81 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 1999
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
## Region code section, this is used to map a region code to a charset name
|
||||
## It have higher priority than the Script code section
|
||||
##
|
||||
region.68=x-mac-croatian
|
||||
region.25=x-mac-croatian
|
||||
region.20=x-mac-greek
|
||||
region.21=x-mac-icelandic
|
||||
region.39=x-mac-romanian
|
||||
region.24=x-mac-turkish
|
||||
##
|
||||
## Script code section, this is used to map a script code to a charset name
|
||||
## It have lower priority than the Region code section
|
||||
##
|
||||
script.0=x-mac-roman
|
||||
script.1=Shift_JIS
|
||||
script.2=Big5
|
||||
script.3=EUC-KR
|
||||
script.4=x-mac-arabic
|
||||
script.5=x-mac-hebrew
|
||||
script.6=x-mac-greek
|
||||
script.7=x-mac-cyrillic
|
||||
script.8=x-mac-rsymbol
|
||||
script.9=x-mac-devanagari
|
||||
script.10=x-mac-gurmukhi
|
||||
script.11=x-mac-gujarati
|
||||
script.12=x-mac-oriya
|
||||
script.13=x-mac-bengali
|
||||
script.14=x-mac-tamil
|
||||
script.15=x-mac-telugu
|
||||
script.16=x-mac-kannada
|
||||
script.17=x-mac-malayalam
|
||||
script.18=x-mac-sinhalese
|
||||
script.19=x-mac-burmese
|
||||
script.20=x-mac-khmer
|
||||
script.21=TIS-620
|
||||
script.22=x-mac-lao
|
||||
script.23=x-mac-georgian
|
||||
script.24=x-mac-armenian
|
||||
script.25=GB2312
|
||||
script.26=x-mac-tibetan
|
||||
script.27=x-mac-mongolian
|
||||
script.28=x-mac-ethiopic
|
||||
script.29=x-mac-ce
|
||||
script.30=x-mac-vietnamese
|
||||
script.31=x-mac-extarabic
|
@ -38,7 +38,6 @@
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "pratom.h"
|
||||
#include "nsUConvPropertySearch.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIMacLocale.h"
|
||||
@ -47,10 +46,6 @@
|
||||
#include "nsPlatformCharset.h"
|
||||
#include "nsEncoderDecoderUtils.h"
|
||||
|
||||
static const char* kMacCharsets[][3] = {
|
||||
#include "maccharset.properties.h"
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPlatformCharset, nsIPlatformCharset)
|
||||
|
||||
nsPlatformCharset::nsPlatformCharset()
|
||||
@ -60,90 +55,18 @@ nsPlatformCharset::~nsPlatformCharset()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult nsPlatformCharset::MapToCharset(short script, short region, nsACString& outCharset)
|
||||
{
|
||||
switch (region) {
|
||||
case verUS:
|
||||
case verFrance:
|
||||
case verGermany:
|
||||
outCharset.AssignLiteral("x-mac-roman");
|
||||
return NS_OK;
|
||||
case verJapan:
|
||||
outCharset.AssignLiteral("Shift_JIS");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// try mapping from region then from script
|
||||
nsCAutoString key("region.");
|
||||
key.AppendInt(region, 10);
|
||||
|
||||
nsresult rv = nsUConvPropertySearch::SearchPropertyValue(kMacCharsets,
|
||||
NS_ARRAY_LENGTH(kMacCharsets), key, outCharset);
|
||||
if (NS_FAILED(rv)) {
|
||||
key.AssignLiteral("script.");
|
||||
key.AppendInt(script, 10);
|
||||
rv = nsUConvPropertySearch::SearchPropertyValue(kMacCharsets,
|
||||
NS_ARRAY_LENGTH(kMacCharsets), key, outCharset);
|
||||
// not found in the .property file, assign x-mac-roman
|
||||
if (NS_FAILED(rv)) {
|
||||
outCharset.AssignLiteral("x-mac-roman");
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector, nsACString& oResult)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mCharset.IsEmpty()) {
|
||||
rv = MapToCharset(
|
||||
(short)(0x0000FFFF & ::GetScriptManagerVariable(smSysScript)),
|
||||
(short)(0x0000FFFF & ::GetScriptManagerVariable(smRegionCode)),
|
||||
mCharset);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
switch (selector) {
|
||||
#ifdef XP_MACOSX
|
||||
case kPlatformCharsetSel_FileName:
|
||||
oResult.AssignLiteral("UTF-8");
|
||||
break;
|
||||
#endif
|
||||
case kPlatformCharsetSel_KeyboardInput:
|
||||
rv = MapToCharset(
|
||||
(short) (0x0000FFFF & ::GetScriptManagerVariable(smKeyScript)),
|
||||
kTextRegionDontCare, oResult);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
break;
|
||||
default:
|
||||
oResult = mCharset;
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
oResult.AssignLiteral("UTF-8");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString &oResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIMacLocale> pMacLocale;
|
||||
pMacLocale = do_GetService(NS_MACLOCALE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
short script, language, region;
|
||||
rv = pMacLocale->GetPlatformLocale(localeName, &script, &language, ®ion);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (NS_SUCCEEDED(MapToCharset(script, region, oResult))) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallback
|
||||
oResult.AssignLiteral("x-mac-roman");
|
||||
return NS_SUCCESS_USING_FALLBACK_LOCALE;
|
||||
oResult.AssignLiteral("UTF-8");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -56,7 +56,6 @@ private:
|
||||
nsCString mCharset;
|
||||
nsString mLocale; // remember the locale & charset
|
||||
|
||||
nsresult MapToCharset(short script, short region, nsACString& outCharset);
|
||||
nsresult MapToCharset(nsAString& inANSICodePage, nsACString& outCharset);
|
||||
nsresult InitGetCharset(nsACString& oString);
|
||||
nsresult ConvertLocaleToCharsetUsingDeprecatedConfig(nsAString& locale, nsACString& oResult);
|
||||
|
@ -143,12 +143,6 @@ nsPlatformCharset::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(short script, short region, nsACString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsACString &oString)
|
||||
{
|
||||
|
@ -122,12 +122,6 @@ nsPlatformCharset::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::MapToCharset(short script, short region, nsACString& outCharset)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPlatformCharset::InitGetCharset(nsACString &oString)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user