Remove native uconv. Bug 644801, r=smontagu

This commit is contained in:
Masatoshi Kimura 2011-04-05 11:13:21 +03:00
parent 157bd1d75c
commit 0db310191f
15 changed files with 1 additions and 1113 deletions

View File

@ -241,9 +241,6 @@
#endif
@BINPATH@/components/txtsvc.xpt
@BINPATH@/components/txmgr.xpt
#ifdef MOZ_USE_NATIVE_UCONV
@BINPATH@/components/ucnative.xpt
#endif
@BINPATH@/components/uconv.xpt
@BINPATH@/components/unicharutil.xpt
@BINPATH@/components/update.xpt

View File

@ -127,7 +127,6 @@ ENABLE_TESTS = @ENABLE_TESTS@
IBMBIDI = @IBMBIDI@
MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHARDET@
ACCESSIBILITY = @ACCESSIBILITY@
MOZ_USE_NATIVE_UCONV = @MOZ_USE_NATIVE_UCONV@
MOZ_BRANDING_DIRECTORY = @MOZ_BRANDING_DIRECTORY@
XPCOM_USE_LEA = @XPCOM_USE_LEA@
MOZ_INSTALLER = @MOZ_INSTALLER@

View File

@ -5000,7 +5000,6 @@ MOZ_TOOLKIT_SEARCH=1
MOZ_UI_LOCALE=en-US
MOZ_UNIVERSALCHARDET=1
MOZ_URL_CLASSIFIER=
MOZ_USE_NATIVE_UCONV=
MOZ_XSLT_STANDALONE=
MOZ_XTF=1
MOZ_XUL=1
@ -5901,20 +5900,6 @@ if test "$NS_PRINTING"; then
AC_DEFINE(NS_PRINTING)
AC_DEFINE(NS_PRINT_PREVIEW)
fi
dnl ========================================================
dnl use native unicode converters
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(native-uconv,
[ --enable-native-uconv Enable iconv support],
MOZ_USE_NATIVE_UCONV=1,
MOZ_USE_NATIVE_UCONV= )
if test "$MOZ_USE_NATIVE_UCONV"; then
AC_DEFINE(MOZ_USE_NATIVE_UCONV)
fi
if test "$OS_ARCH" != "WINCE" -a "$OS_ARCH" != "WINNT" -a "$MOZ_USE_NATIVE_UCONV" -a "$ac_cv_func_iconv" != "yes"; then
AC_MSG_ERROR([iconv() not found. Cannot enable native uconv support.])
fi
dnl ========================================================
dnl = Disable Fast Load
@ -9056,7 +9041,6 @@ AC_SUBST(MOZ_SHARK)
AC_SUBST(MOZ_CALLGRIND)
AC_SUBST(MOZ_VTUNE)
AC_SUBST(MOZ_PROFILING)
AC_SUBST(MOZ_USE_NATIVE_UCONV)
AC_SUBST(MOZ_QUANTIFY)
AC_SUBST(LIBICONV)
AC_SUBST(MOZ_PLACES)

View File

@ -57,15 +57,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = uconv
DIRS = idl public util
ifdef MOZ_USE_NATIVE_UCONV
DIRS += native
else
DIRS += ucvja ucvcn ucvlatin ucvtw ucvtw2 ucvko ucvibm
endif
DIRS += src
DIRS = idl public util ucvja ucvcn ucvlatin ucvtw ucvtw2 ucvko ucvibm src
ifdef ENABLE_TESTS
TOOL_DIRS += tests

View File

@ -2,7 +2,6 @@ Directory Structure :
================================
idl - public .idl files
native - support for native platform charset conversion
public - public header file
src - source directory of charset converter manager and utilities, and
charset converters for ISO-8859-1, CP1252, MacRoman and UTF-8

View File

@ -1,64 +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 mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of 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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = ucnative
LIBRARY_NAME = ucnative_s
FORCE_STATIC_LIB=1
LIBXUL_LIBRARY = 1
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS = nsWinCEUConvService.cpp
else
CPPSRCS = nsNativeUConvService.cpp
endif
XPIDLSRCS = \
nsINativeUConvService.idl \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)/../util -I$(srcdir)/../src
include $(topsrcdir)/config/rules.mk

View File

@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 a Native UCONV interface.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#include "nsISupports.idl"
/*
* Returns an object that implements the following interfaces:
*
* nsIUnicodeDecoder
* nsIUnicodeEncoder
*/
[uuid(c60097ba-c79d-461b-9116-80a66404c0b0)]
interface nsINativeUConvService : nsISupports
{
nsISupports getNativeConverter(in string from, in string to);
};

View File

@ -1,393 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#ifdef MOZ_USE_NATIVE_UCONV
#include "nsString.h"
#include "nsIGenericFactory.h"
#include "nsINativeUConvService.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeEncoder.h"
#include "nsNativeUConvService.h"
#include "nsAutoPtr.h"
#include <nl_types.h> // CODESET
#include <langinfo.h> // nl_langinfo
#include <iconv.h> // iconv_open, iconv, iconv_close
#include <errno.h>
class IConvAdaptor : public nsIUnicodeDecoder,
public nsIUnicodeEncoder
{
public:
IConvAdaptor();
virtual ~IConvAdaptor();
nsresult Init(const char* from, const char* to);
NS_DECL_ISUPPORTS
// Decoder methods:
NS_IMETHOD Convert(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const char * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
virtual void SetInputErrorBehavior(PRInt32 aBehavior);
virtual PRUnichar GetCharacterForUnMapped();
// Encoder methods:
NS_IMETHOD Convert(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength);
NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength);
// defined by the Decoder: NS_IMETHOD Reset();
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar);
private:
nsresult ConvertInternal(void * aSrc,
PRInt32 * aSrcLength,
PRInt32 aSrcCharSize,
void * aDest,
PRInt32 * aDestLength,
PRInt32 aDestCharSize);
iconv_t mConverter;
PRBool mReplaceOnError;
PRUnichar mReplaceChar;
#ifdef DEBUG
nsCString mFrom, mTo;
#endif
};
NS_IMPL_ISUPPORTS2(IConvAdaptor,
nsIUnicodeEncoder,
nsIUnicodeDecoder)
IConvAdaptor::IConvAdaptor()
{
mConverter = 0;
mReplaceOnError = PR_FALSE;
}
IConvAdaptor::~IConvAdaptor()
{
if (mConverter)
iconv_close(mConverter);
}
nsresult
IConvAdaptor::Init(const char* from, const char* to)
{
#ifdef DEBUG
mFrom = from;
mTo = to;
#endif
mConverter = iconv_open(to, from);
if (mConverter == (iconv_t) -1 )
{
#ifdef DEBUG
printf(" * IConvAdaptor - FAILED Initing: %s ==> %s\n", from, to);
#endif
mConverter = nsnull;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
// From some charset to ucs2
nsresult
IConvAdaptor::Convert(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength)
{
return ConvertInternal( (void*) aSrc,
aSrcLength,
1,
(void*) aDest,
aDestLength,
2);
}
nsresult
IConvAdaptor::GetMaxLength(const char * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
if (!mConverter)
return NS_ERROR_UENC_NOMAPPING;
*aDestLength = aSrcLength*4; // sick
#ifdef DEBUG
printf(" * IConvAdaptor - - GetMaxLength %d ( %s -> %s )\n", *aDestLength, mFrom.get(), mTo.get());
#endif
return NS_OK;
}
nsresult
IConvAdaptor::Reset()
{
const char *zero_char_in_ptr = NULL;
char *zero_char_out_ptr = NULL;
size_t zero_size_in = 0,
zero_size_out = 0;
iconv(mConverter,
(char **)&zero_char_in_ptr,
&zero_size_in,
&zero_char_out_ptr,
&zero_size_out);
#ifdef DEBUG
printf(" * IConvAdaptor - - Reset\n");
#endif
return NS_OK;
}
void
IConvAdaptor::SetInputErrorBehavior(PRInt32 aBehavior)
{
}
PRUnichar
IConvAdaptor::GetCharacterForUnMapped()
{
return PRUnichar(0xfffd); // Unicode REPLACEMENT CHARACTER
}
// convert unicode data into some charset.
nsresult
IConvAdaptor::Convert(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
return ConvertInternal( (void*) aSrc,
aSrcLength,
2,
(void*) aDest,
aDestLength,
1);
}
nsresult
IConvAdaptor::Finish(char * aDest, PRInt32 * aDestLength)
{
*aDestLength = 0;
return NS_OK;
}
nsresult
IConvAdaptor::GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
if (!mConverter)
return NS_ERROR_UENC_NOMAPPING;
*aDestLength = aSrcLength*4; // sick
return NS_OK;
}
nsresult
IConvAdaptor::SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar)
{
if (aBehavior == nsIUnicodeEncoder::kOnError_Signal) {
mReplaceOnError = PR_FALSE;
return NS_OK;
}
else if (aBehavior == nsIUnicodeEncoder::kOnError_Replace) {
mReplaceOnError = PR_TRUE;
mReplaceChar = aChar;
return NS_OK;
}
NS_WARNING("Uconv Error Behavior not support");
return NS_ERROR_FAILURE;
}
nsresult
IConvAdaptor::ConvertInternal(void * aSrc,
PRInt32 * aSrcLength,
PRInt32 aSrcCharSize,
void * aDest,
PRInt32 * aDestLength,
PRInt32 aDestCharSize)
{
if (!mConverter) {
NS_WARNING("Converter Not Initialize");
return NS_ERROR_NOT_INITIALIZED;
}
size_t res = 0;
size_t inLeft = (size_t) *aSrcLength * aSrcCharSize;
size_t outLeft = (size_t) *aDestLength * aDestCharSize;
size_t outputAvail = outLeft;
while (true){
res = iconv(mConverter,
(char**)&aSrc,
&inLeft,
(char**)&aDest,
&outLeft);
if (res == (size_t) -1) {
// on some platforms (e.g., linux) iconv will fail with
// E2BIG if it cannot convert _all_ of its input. it'll
// still adjust all of the in/out params correctly, so we
// can ignore this error. the assumption is that we will
// be called again to complete the conversion.
if ((errno == E2BIG) && (outLeft < outputAvail)) {
res = 0;
break;
}
if (errno == EILSEQ) {
if (mReplaceOnError) {
if (aDestCharSize == 1) {
(*(char*)aDest) = (char)mReplaceChar;
aDest = (char*)aDest + sizeof(char);
}
else
{
(*(PRUnichar*)aDest) = (PRUnichar)mReplaceChar;
aDest = (PRUnichar*)aDest + sizeof(PRUnichar);
}
inLeft -= aSrcCharSize;
outLeft -= aDestCharSize;
#ifdef DEBUG
printf(" * IConvAdaptor - replacing char in output ( %s -> %s )\n",
mFrom.get(), mTo.get());
#endif
res = 0;
}
}
if (res == -1) {
#ifdef DEBUG
printf(" * IConvAdaptor - Bad input ( %s -> %s )\n", mFrom.get(), mTo.get());
#endif
return NS_ERROR_UENC_NOMAPPING;
}
}
if (inLeft <= 0 || outLeft <= 0 || res == -1)
break;
}
if (res != (size_t) -1) {
// xp_iconv deals with how much is remaining in a given buffer
// but what uconv wants how much we read/written already. So
// we fix it up here.
*aSrcLength -= (inLeft / aSrcCharSize);
*aDestLength -= (outLeft / aDestCharSize);
return NS_OK;
}
#ifdef DEBUG
printf(" * IConvAdaptor - - xp_iconv error( %s -> %s )\n", mFrom.get(), mTo.get());
#endif
Reset();
return NS_ERROR_UENC_NOMAPPING;
}
NS_IMPL_ISUPPORTS1(NativeUConvService, nsINativeUConvService)
NS_IMETHODIMP
NativeUConvService::GetNativeConverter(const char* from,
const char* to,
nsISupports** aResult)
{
*aResult = nsnull;
//nsRefPtr<IConvAdaptor> ucl = new IConvAdaptor();
IConvAdaptor *adaptor=new IConvAdaptor();
nsCOMPtr<nsISupports> ucl(static_cast<nsIUnicodeDecoder*>(adaptor));
if (!ucl)
return NS_ERROR_OUT_OF_MEMORY;
//nsresult rv = ucl->Init(from, to);
nsresult rv=adaptor->Init(from,to);
if (NS_SUCCEEDED(rv))
NS_ADDREF(*aResult = ucl);
return rv;
}
#endif

View File

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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 a Native UCONV interface.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of 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 ***** */
#define NS_NATIVE_UCONV_SERVICE_CONTRACT_ID "@mozilla.org/uconv/native-service"
#define NS_NATIVE_UCONV_SERVICE_CID \
{ 0xbd3e94ba, 0xd46f, 0x4026, \
{ 0xa1, 0xc3, 0x6e, 0xd0, 0xc1, 0x6e, 0xa0, 0x22 } }
#include "nsINativeUConvService.h"
class NativeUConvService : public nsINativeUConvService
{
public:
NativeUConvService() {};
virtual ~NativeUConvService() {};
NS_DECL_ISUPPORTS
NS_DECL_NSINATIVEUCONVSERVICE
};

View File

@ -1,442 +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 WinCEUConvAdapter for Windows CE
*
* The Initial Developer of the Original Code is
* Doug Turner <dougt@meer.net>.
* Portions created by the Initial Developer are Copyright (C) 2005
* 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 ***** */
#include <windows.h>
#include "nsNativeUConvService.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeEncoder.h"
#include "nsIPlatformCharset.h"
#include "nsIServiceManager.h"
#include "nsUCSupport.h"
#include "nsUTF8ToUnicode.h"
#include "nsUnicodeToUTF8.h"
#ifdef ALERT_DBG
void DisplayLastError(const char * msg)
{
int flags = MB_APPLMODAL | MB_TOPMOST | MB_SETFOREGROUND;
int error = GetLastError();
switch (error)
{
case ERROR_NO_UNICODE_TRANSLATION:
MessageBox(0, "ERROR_NO_UNICODE_TRANSLATION", msg, flags);
break;
case ERROR_INVALID_PARAMETER:
MessageBox(0, "ERROR_INVALID_PARAMETER", msg, flags);
break;
case ERROR_INVALID_FLAGS:
MessageBox(0, "ERROR_INVALID_FLAGS", msg, flags);
break;
case ERROR_INSUFFICIENT_BUFFER:
MessageBox(0, "ERROR_INSUFFICIENT_BUFFER", msg, flags);
break;
default:
MessageBox(0, "other...", msg, flags);
}
}
#endif
class WinCEUConvAdapter : public nsIUnicodeDecoder,
public nsIUnicodeEncoder
{
public:
WinCEUConvAdapter();
virtual ~WinCEUConvAdapter();
nsresult Init(const char* from, const char* to);
NS_DECL_ISUPPORTS;
// Decoder methods:
NS_IMETHOD Convert(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const char * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
virtual void SetInputErrorBehavior(PRInt32 aBehavior);
virtual PRUnichar GetCharacterForUnMapped();
// Encoder methods:
NS_IMETHOD Convert(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength);
NS_IMETHOD Finish(char * aDest, PRInt32 * aDestLength);
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength);
// defined by the Decoder: NS_IMETHOD Reset();
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar);
PRUint32 mCodepage;
};
NS_IMPL_ISUPPORTS2(WinCEUConvAdapter,
nsIUnicodeDecoder,
nsIUnicodeEncoder)
WinCEUConvAdapter::WinCEUConvAdapter()
{
mCodepage = -1;
}
WinCEUConvAdapter::~WinCEUConvAdapter()
{
}
typedef struct CharsetCodePageMap {
char charset[32];
PRUint16 codepage;
} CsCpMap;
static CsCpMap theCsCPMap[] = {
{"Big5", 950},
{"EUC-JP", 51932},
{"EUC-KR", 949},
{"GB2312", 936},
{"HZ-GB-2312 ", 52936},
{"IBM850", 850},
{"IBM852", 852},
{"IBM855", 855},
{"IBM857", 857},
{"IBM862", 862},
{"IBM866", 866},
{"IBM869", 869},
{"ISO-2022-JP", 50220},
{"ISO-2022-KR", 50225},
{"ISO-8859-15", 28605},
{"ISO-8859-1", 28591},
{"ISO-8859-2", 28592},
{"ISO-8859-3", 28593},
{"ISO-8859-4", 28594},
{"ISO-8859-5", 28595},
{"ISO-8859-6", 28596},
{"ISO-8859-7", 28597},
{"ISO-8859-8", 28598},
{"ISO-8859-8-I", 1255},
{"ISO-8859-9", 28599},
{"Shift_JIS", 932},
{"TIS-620", 874},
{"UTF-16", 1200},
{"UTF-7", 65000},
{"UTF-8", 65001},
{"gb_2312-80", 936},
{"ks_c_5601-1987", 949},
{"us-ascii", 20127},
{"windows-1250", 1250},
{"windows-1251", 1251},
{"windows-1252", 1252},
{"windows-1253", 1253},
{"windows-1254", 1254},
{"windows-1255", 1255},
{"windows-1256", 1256},
{"windows-1257", 1257},
{"windows-1258", 1258},
{"windows-874", 874},
{"windows-936", 936},
{"x-mac-arabic", 10004},
{"x-mac-ce", 10029},
{"x-mac-cyrillic", 10007},
{"x-mac-greek", 10006},
{"x-mac-hebrew", 10005},
{"x-mac-icelandi", 10079},
{"x-x-big5", 950},
{nsnull, 0}
};
nsresult
WinCEUConvAdapter::Init(const char* from, const char* to)
{
const char* cpstring = nsnull;
if (!strcmp(from, "UCS-2"))
{
cpstring = to;
}
else
{
cpstring = from;
}
int i = 0;
while (1)
{
if (theCsCPMap[i].charset[0] == nsnull)
break;
if (!strcmp(theCsCPMap[i].charset, cpstring))
{
mCodepage = theCsCPMap[i].codepage;
break;
}
i++;
}
if (mCodepage == -1)
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_IMETHODIMP
WinCEUConvAdapter::Convert(const char * aSrc,
PRInt32 * aSrcLength,
PRUnichar * aDest,
PRInt32 * aDestLength)
{
if (mCodepage == -1)
return NS_ERROR_FAILURE;
int count = MultiByteToWideChar(mCodepage,
0,
aSrc,
*aSrcLength,
aDest,
*aDestLength);
if (count == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
{
// fall back on the current system Windows "ANSI" code page
count = MultiByteToWideChar(CP_ACP,
0,
aSrc,
*aSrcLength,
aDest,
*aDestLength);
}
#ifdef ALERT_DBG
if (count == 0)
DisplayLastError("MultiByteToWideChar");
#endif
*aDestLength = count;
*aSrcLength = count;
return NS_OK;
}
NS_IMETHODIMP
WinCEUConvAdapter::GetMaxLength(const char * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
if (mCodepage == -1 || aSrc == nsnull )
return NS_ERROR_FAILURE;
int count = MultiByteToWideChar(mCodepage,
MB_PRECOMPOSED,
aSrc,
aSrcLength,
NULL,
NULL);
if (count == 0 && GetLastError() == ERROR_INVALID_PARAMETER)
{
// fall back on the current system Windows "ANSI" code page
count = MultiByteToWideChar(CP_ACP,
MB_PRECOMPOSED,
aSrc,
aSrcLength,
NULL,
NULL);
}
#ifdef ALERT_DBG
if (count == 0)
DisplayLastError("MultiByteToWideChar (0)");
#endif
*aDestLength = count;
return NS_OK;
}
NS_IMETHODIMP
WinCEUConvAdapter::Reset()
{
return NS_OK;
}
void
WinCEUConvAdapter::SetInputErrorBehavior(PRInt32 aBehavior)
{
}
PRUnichar
WinCEUConvAdapter::GetCharacterForUnMapped()
{
return PRUnichar(0xfffd); // Unicode REPLACEMENT CHARACTER
}
// Encoder methods:
NS_IMETHODIMP
WinCEUConvAdapter::Convert(const PRUnichar * aSrc,
PRInt32 * aSrcLength,
char * aDest,
PRInt32 * aDestLength)
{
if (mCodepage == -1)
return NS_ERROR_FAILURE;
char * defaultChar = "?";
int count = WideCharToMultiByte(mCodepage,
0,
aSrc,
*aSrcLength,
aDest,
*aDestLength,
defaultChar,
NULL);
#ifdef ALERT_DBG
if (count == 0)
DisplayLastError("WideCharToMultiByte");
#endif
*aSrcLength = count;
*aDestLength = count;
return NS_OK;
}
NS_IMETHODIMP
WinCEUConvAdapter::Finish(char * aDest, PRInt32 * aDestLength)
{
*aDestLength = 0;
return NS_OK;
}
NS_IMETHODIMP
WinCEUConvAdapter::GetMaxLength(const PRUnichar * aSrc,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
if (mCodepage == -1)
return NS_ERROR_FAILURE;
int count = WideCharToMultiByte(mCodepage,
0,
aSrc,
aSrcLength,
NULL,
NULL,
NULL,
NULL);
#ifdef ALERT_DBG
if (count == 0)
DisplayLastError("WideCharToMultiByte (0)");
#endif
*aDestLength = count;
return NS_OK;
}
// defined by the Decoder: NS_IMETHOD Reset();
NS_IMETHODIMP
WinCEUConvAdapter::SetOutputErrorBehavior(PRInt32 aBehavior,
nsIUnicharEncoder * aEncoder,
PRUnichar aChar)
{
return NS_OK;
}
// NativeUConvService
NS_IMPL_ISUPPORTS1(NativeUConvService,
nsINativeUConvService);
NS_IMETHODIMP
NativeUConvService::GetNativeConverter(const char* from,
const char* to,
nsISupports** aResult)
{
*aResult = nsnull;
if (!strcmp(from, "UCS-2") &&
!strcmp(to, "UTF-8") )
{
nsUnicodeToUTF8 * inst = new nsUnicodeToUTF8();
inst->AddRef();
*aResult = inst;
return NS_OK;
}
if (!strcmp(from, "UTF-8") &&
!strcmp(to, "UCS-2") )
{
nsUTF8ToUnicode * inst = new nsUTF8ToUnicode();
inst->AddRef();
*aResult = (nsIUnicodeDecoder*) inst;
return NS_OK;
}
WinCEUConvAdapter* ucl = new WinCEUConvAdapter();
if (!ucl)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = ucl->Init(from, to);
if (NS_SUCCEEDED(rv)) {
NS_ADDREF(*aResult = (nsISupports*)(nsIUnicharEncoder*)ucl);
}
return rv;
}

View File

@ -62,10 +62,6 @@ CPPSRCS = \
nsUTF8ToUnicode.cpp \
nsUnicodeToUTF8.cpp \
nsScriptableUConv.cpp \
$(NULL)
ifndef MOZ_USE_NATIVE_UCONV
CPPSRCS += \
nsISO88591ToUnicode.cpp \
nsCP1252ToUnicode.cpp \
nsMacRomanToUnicode.cpp \
@ -73,7 +69,6 @@ CPPSRCS += \
nsUnicodeToCP1252.cpp \
nsUnicodeToMacRoman.cpp \
$(NULL)
endif
# Are we targeting x86-32 or x86-64? If so, we want to include the SSE2
# version of nsUTF8ToUnicodeSSE2.cpp.
@ -112,10 +107,8 @@ LOCAL_INCLUDES = -I$(srcdir)/../util \
-I$(srcdir)/../ucvtw \
-I$(srcdir)/../ucvko \
-I$(srcdir)/../ucvcn \
-I$(srcdir)/../native \
$(NULL)
ifndef MOZ_USE_NATIVE_UCONV
SHARED_LIBRARY_LIBS += \
../ucvlatin/$(LIB_PREFIX)ucvlatin_s.$(LIB_SUFFIX) \
../ucvibm/$(LIB_PREFIX)ucvibm_s.$(LIB_SUFFIX) \
@ -125,10 +118,5 @@ SHARED_LIBRARY_LIBS += \
../ucvko/$(LIB_PREFIX)ucvko_s.$(LIB_SUFFIX) \
../ucvcn/$(LIB_PREFIX)ucvcn_s.$(LIB_SUFFIX) \
$(NULL)
else
SHARED_LIBRARY_LIBS += \
../native/$(LIB_PREFIX)ucnative_s.$(LIB_SUFFIX) \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -61,10 +61,6 @@
// just for CONTRACTIDs
#include "nsCharsetConverterManager.h"
#ifdef MOZ_USE_NATIVE_UCONV
#include "nsNativeUConvService.h"
#endif
// Class nsCharsetConverterManager [implementation]
NS_IMPL_THREADSAFE_ISUPPORTS1(nsCharsetConverterManager,
@ -154,21 +150,6 @@ nsCharsetConverterManager::GetUnicodeEncoderRaw(const char * aDest,
*aResult= nsnull;
nsCOMPtr<nsIUnicodeEncoder> encoder;
#ifdef MOZ_USE_NATIVE_UCONV
if (mNativeUC) {
nsCOMPtr<nsISupports> supports;
mNativeUC->GetNativeConverter("UCS-2",
aDest,
getter_AddRefs(supports));
encoder = do_QueryInterface(supports);
if (encoder) {
NS_ADDREF(*aResult = encoder);
return NS_OK;
}
}
#endif
nsresult rv = NS_OK;
nsCAutoString
@ -237,21 +218,6 @@ nsCharsetConverterManager::GetUnicodeDecoderRawInternal(const char * aSrc,
*aResult= nsnull;
nsCOMPtr<nsIUnicodeDecoder> decoder;
#ifdef MOZ_USE_NATIVE_UCONV
if (mNativeUC) {
nsCOMPtr<nsISupports> supports;
mNativeUC->GetNativeConverter(aSrc,
"UCS-2",
getter_AddRefs(supports));
decoder = do_QueryInterface(supports);
if (decoder) {
NS_ADDREF(*aResult = decoder);
return NS_OK;
}
}
#endif
nsresult rv = NS_OK;
NS_NAMED_LITERAL_CSTRING(contractbase, NS_UNICODEDECODER_CONTRACTID_BASE);

View File

@ -43,10 +43,6 @@
#include "nsInterfaceHashtable.h"
#include "mozilla/Mutex.h"
#ifdef MOZ_USE_NATIVE_UCONV
#include "nsINativeUConvService.h"
#endif
class nsCharsetConverterManager : public nsICharsetConverterManager
{
NS_DECL_ISUPPORTS
@ -62,10 +58,6 @@ private:
nsIStringBundle * mDataBundle;
nsIStringBundle * mTitleBundle;
#ifdef MOZ_USE_NATIVE_UCONV
nsCOMPtr<nsINativeUConvService> mNativeUC;
#endif
nsresult LoadExtensibleBundle(const char * aRegistryKey,
nsIStringBundle ** aResult);

View File

@ -56,7 +56,6 @@
#include "nsConverterOutputStream.h"
#include "nsScriptableUConv.h"
#ifndef MOZ_USE_NATIVE_UCONV
#include "nsITextToSubURI.h"
#include "nsUConvDll.h"
@ -562,15 +561,6 @@ const PRUint16 g_ufJohabJamoMapping[] ={
#include "johabjamo.uf"
};
#else // MOZ_USE_NATIVE_UCONV
#include "nsINativeUConvService.h"
#include "nsNativeUConvService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(NativeUConvService)
#endif // #ifndef MOZ_USE_NATIVE_UCONV
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCharsetConverterManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextToSubURI)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUTF8ConverterService)
@ -583,9 +573,6 @@ NS_DEFINE_NAMED_CID(NS_TEXTTOSUBURI_CID);
NS_DEFINE_NAMED_CID(NS_CONVERTERINPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_CONVERTEROUTPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_ISCRIPTABLEUNICODECONVERTER_CID);
#ifdef MOZ_USE_NATIVE_UCONV
NS_DEFINE_NAMED_CID(NS_NATIVE_UCONV_SERVICE_CID);
#else
NS_DEFINE_NAMED_CID(NS_UTF8CONVERTERSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_ISO88591TOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_CP1252TOUNICODE_CID);
@ -772,7 +759,6 @@ NS_DEFINE_NAMED_CID(NS_UNICODETOHZ_CID);
NS_DEFINE_NAMED_CID(NS_GB18030TOUNICODE_CID);
NS_DEFINE_NAMED_CID(NS_UNICODETOGB18030_CID);
NS_DEFINE_NAMED_CID(NS_ISO2022CNTOUNICODE_CID);
#endif
static const mozilla::Module::CIDEntry kUConvCIDs[] = {
{ &kNS_ICHARSETCONVERTERMANAGER_CID, false, NULL, nsCharsetConverterManagerConstructor },
@ -780,9 +766,6 @@ static const mozilla::Module::CIDEntry kUConvCIDs[] = {
{ &kNS_CONVERTERINPUTSTREAM_CID, false, NULL, nsConverterInputStreamConstructor },
{ &kNS_CONVERTEROUTPUTSTREAM_CID, false, NULL, nsConverterOutputStreamConstructor },
{ &kNS_ISCRIPTABLEUNICODECONVERTER_CID, false, NULL, nsScriptableUnicodeConverterConstructor },
#ifdef MOZ_USE_NATIVE_ICONV
{ &kNS_NATIVE_UCONV_SERVICE_CID, false, NULL, NativeUConvServiceConstructor },
#else
{ &kNS_UTF8CONVERTERSERVICE_CID, false, NULL, nsUTF8ConverterServiceConstructor },
{ &kNS_ISO88591TOUNICODE_CID, false, NULL, nsISO88591ToUnicodeConstructor },
{ &kNS_CP1252TOUNICODE_CID, false, NULL, nsCP1252ToUnicodeConstructor },
@ -969,7 +952,6 @@ static const mozilla::Module::CIDEntry kUConvCIDs[] = {
{ &kNS_GB18030TOUNICODE_CID, false, NULL, nsGB18030ToUnicodeConstructor },
{ &kNS_UNICODETOGB18030_CID, false, NULL, nsUnicodeToGB18030Constructor },
{ &kNS_ISO2022CNTOUNICODE_CID, false, NULL, nsISO2022CNToUnicodeConstructor },
#endif
{ NULL },
};
@ -979,9 +961,6 @@ static const mozilla::Module::ContractIDEntry kUConvContracts[] = {
{ NS_CONVERTERINPUTSTREAM_CONTRACTID, &kNS_CONVERTERINPUTSTREAM_CID },
{ "@mozilla.org/intl/converter-output-stream;1", &kNS_CONVERTEROUTPUTSTREAM_CID },
{ NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID, &kNS_ISCRIPTABLEUNICODECONVERTER_CID },
#ifdef MOZ_USE_NATIVE_ICONV
{ NS_NATIVE_UCONV_SERVICE_CONTRACT_ID, &kNS_NATIVE_UCONV_SERVICE_CID },
#else
{ NS_UTF8CONVERTERSERVICE_CONTRACTID, &kNS_UTF8CONVERTERSERVICE_CID },
{ NS_ISO88591TOUNICODE_CONTRACTID, &kNS_ISO88591TOUNICODE_CID },
{ NS_CP1252TOUNICODE_CONTRACTID, &kNS_CP1252TOUNICODE_CID },
@ -1168,7 +1147,6 @@ static const mozilla::Module::ContractIDEntry kUConvContracts[] = {
{ NS_UNICODEDECODER_CONTRACTID_BASE "gb18030", &kNS_GB18030TOUNICODE_CID },
{ NS_UNICODEENCODER_CONTRACTID_BASE "gb18030", &kNS_UNICODETOGB18030_CID },
{ NS_UNICODEDECODER_CONTRACTID_BASE "ISO-2022-CN", &kNS_ISO2022CNTOUNICODE_CID },
#endif
{ NULL }
};

View File

@ -160,7 +160,6 @@ MAKEFILES_intl="
intl/uconv/ucvtw2/Makefile
intl/uconv/ucvko/Makefile
intl/uconv/ucvibm/Makefile
intl/uconv/native/Makefile
intl/locale/Makefile
intl/locale/public/Makefile
intl/locale/idl/Makefile