This commit is contained in:
ftang%netscape.com 1999-01-14 07:35:24 +00:00
Родитель 5c29b5f5e9
Коммит a267ebb98a
16 изменённых файлов: 1749 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,123 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*========================================================
This is a Generated file. Please don't edit it.
The tool which used to generate this file is called fromu.
If you have any problem of this file. Please contact
Netscape Client International Team or
ftang@netscape <Frank Tang>
Table in Debug form
Begin of Item 0000
Format 0
srcBegin = 0020
srcEnd = 007E
destBegin = 0020
End of Item 0000
Begin of Item 0001
Format 0
srcBegin = 038E
srcEnd = 03A1
destBegin = 00BE
End of Item 0001
Begin of Item 0002
Format 0
srcBegin = 03A3
srcEnd = 03CE
destBegin = 00D3
End of Item 0002
Begin of Item 0003
Format 1
srcBegin = 00A0
srcEnd = 00BD
mappingOffset = 0000
Mapping =
00A0 FFFD FFFD 00A3 FFFD FFFD 00A6 00A7
00A8 00A9 FFFD 00AB 00AC 00AD FFFD FFFD
00B0 00B1 00B2 00B3 FFFD FFFD FFFD 00B7
FFFD FFFD FFFD 00BB FFFD 00BD
End of Item 0003
Begin of Item 0004
Format 1
srcBegin = 02BC
srcEnd = 02BD
mappingOffset = 001E
Mapping =
00A2 00A1
End of Item 0004
Begin of Item 0005
Format 1
srcBegin = 0384
srcEnd = 038C
mappingOffset = 0020
Mapping =
00B4 00B5 00B6 FFFD 00B8 00B9 00BA FFFD
00BC
End of Item 0005
Begin of Item 0006
Format 2
srcBegin = 2015
destBegin = 00AF
End of Item 0006
========================================================*/
/* Offset=0x0000 ItemOfList */
0x0007,
/*-------------------------------------------------------*/
/* Offset=0x0001 offsetToFormatArray */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0002 offsetToMapCellArray */
0x0006,
/*-------------------------------------------------------*/
/* Offset=0x0003 offsetToMappingTable */
0x001B,
/*-------------------------------------------------------*/
/* Offset=0x0004 Start of Format Array */
/* Total of Format 0 : 0x0003 */
/* Total of Format 1 : 0x0003 */
/* Total of Format 2 : 0x0001 */
/* Total of Format 3 : 0x0000 */
0x1000, 0x0211,
/*-------------------------------------------------------*/
/* Offset=0x0006 Start of MapCell Array */
/* 0000 */ 0x0020, 0x007E, 0x0020,
/* 0001 */ 0x038E, 0x03A1, 0x00BE,
/* 0002 */ 0x03A3, 0x03CE, 0x00D3,
/* 0003 */ 0x00A0, 0x00BD, 0x0000,
/* 0004 */ 0x02BC, 0x02BD, 0x001E,
/* 0005 */ 0x0384, 0x038C, 0x0020,
/* 0006 */ 0x2015, 0x0000, 0x00AF,
/*-------------------------------------------------------*/
/* Offset=0x001B Start of MappingTable */
/* 0000 */ 0x00A0, 0xFFFD, 0xFFFD, 0x00A3, 0xFFFD, 0xFFFD, 0x00A6, 0x00A7,
/* 0008 */ 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0xFFFD, 0xFFFD,
/* 0010 */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0xFFFD, 0xFFFD, 0xFFFD, 0x00B7,
/* 0018 */ 0xFFFD, 0xFFFD, 0xFFFD, 0x00BB, 0xFFFD, 0x00BD, 0x00A2, 0x00A1,
/* 0020 */ 0x00B4, 0x00B5, 0x00B6, 0xFFFD, 0x00B8, 0x00B9, 0x00BA, 0xFFFD,
/* 0028 */ 0x00BC,
/* End of table Total Length = 0x0044 * 2 */

Просмотреть файл

@ -0,0 +1,93 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*========================================================
This is a Generated file. Please don't edit it.
The tool which used to generate this file is called fromu.
If you have any problem of this file. Please contact
Netscape Client International Team or
ftang@netscape <Frank Tang>
Table in Debug form
Begin of Item 0000
Format 0
srcBegin = 0020
srcEnd = 007E
destBegin = 0020
End of Item 0000
Begin of Item 0001
Format 0
srcBegin = 00BE
srcEnd = 00D1
destBegin = 038E
End of Item 0001
Begin of Item 0002
Format 0
srcBegin = 00D3
srcEnd = 00FE
destBegin = 03A3
End of Item 0002
Begin of Item 0003
Format 1
srcBegin = 00A0
srcEnd = 00BD
mappingOffset = 0000
Mapping =
00A0 02BD 02BC 00A3 FFFD FFFD 00A6 00A7
00A8 00A9 FFFD 00AB 00AC 00AD FFFD 2015
00B0 00B1 00B2 00B3 0384 0385 0386 00B7
0388 0389 038A 00BB 038C 00BD
End of Item 0003
========================================================*/
/* Offset=0x0000 ItemOfList */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0001 offsetToFormatArray */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0002 offsetToMapCellArray */
0x0006,
/*-------------------------------------------------------*/
/* Offset=0x0003 offsetToMappingTable */
0x0012,
/*-------------------------------------------------------*/
/* Offset=0x0004 Start of Format Array */
/* Total of Format 0 : 0x0003 */
/* Total of Format 1 : 0x0001 */
/* Total of Format 2 : 0x0000 */
/* Total of Format 3 : 0x0000 */
0x1000, 0x0000,
/*-------------------------------------------------------*/
/* Offset=0x0006 Start of MapCell Array */
/* 0000 */ 0x0020, 0x007E, 0x0020,
/* 0001 */ 0x00BE, 0x00D1, 0x038E,
/* 0002 */ 0x00D3, 0x00FE, 0x03A3,
/* 0003 */ 0x00A0, 0x00BD, 0x0000,
/*-------------------------------------------------------*/
/* Offset=0x0012 Start of MappingTable */
/* 0000 */ 0x00A0, 0x02BD, 0x02BC, 0x00A3, 0xFFFD, 0xFFFD, 0x00A6, 0x00A7,
/* 0008 */ 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0xFFFD, 0x2015,
/* 0010 */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7,
/* 0018 */ 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD,
/* End of table Total Length = 0x0030 * 2 */

Просмотреть файл

@ -0,0 +1,153 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*========================================================
This is a Generated file. Please don't edit it.
The tool which used to generate this file is called fromu.
If you have any problem of this file. Please contact
Netscape Client International Team or
ftang@netscape <Frank Tang>
Table in Debug form
Begin of Item 0000
Format 0
srcBegin = 0000
srcEnd = 007F
destBegin = 0000
End of Item 0000
Begin of Item 0001
Format 0
srcBegin = 00A3
srcEnd = 00A9
destBegin = 00A3
End of Item 0001
Begin of Item 0002
Format 0
srcBegin = 038E
srcEnd = 03A1
destBegin = 00BE
End of Item 0002
Begin of Item 0003
Format 0
srcBegin = 03A3
srcEnd = 03CE
destBegin = 00D3
End of Item 0003
Begin of Item 0004
Format 1
srcBegin = 00A0
srcEnd = 00BD
mappingOffset = 0000
Mapping =
00A0 FFFD FFFD FFFD FFFD FFFD FFFD FFFD
FFFD FFFD FFFD 00AB 00AC 00AD 00AE FFFD
00B0 00B1 00B2 00B3 FFFD 00B5 00B6 00B7
FFFD FFFD FFFD 00BB FFFD 00BD
End of Item 0004
Begin of Item 0005
Format 2
srcBegin = 0192
destBegin = 0083
End of Item 0005
Begin of Item 0006
Format 1
srcBegin = 0384
srcEnd = 038C
mappingOffset = 001E
Mapping =
00B4 00A1 00A2 FFFD 00B8 00B9 00BA FFFD
00BC
End of Item 0006
Begin of Item 0007
Format 1
srcBegin = 2013
srcEnd = 203A
mappingOffset = 0027
Mapping =
0096 0097 00AF FFFD FFFD 0091 0092 0082
FFFD 0093 0094 0084 FFFD 0086 0087 0095
FFFD FFFD FFFD 0085 FFFD FFFD FFFD FFFD
FFFD FFFD FFFD FFFD FFFD 0089 FFFD FFFD
FFFD FFFD FFFD FFFD FFFD FFFD 008B 009B
End of Item 0007
Begin of Item 0008
Format 2
srcBegin = 20AC
destBegin = 0080
End of Item 0008
Begin of Item 0009
Format 2
srcBegin = 2122
destBegin = 0099
End of Item 0009
========================================================*/
/* Offset=0x0000 ItemOfList */
0x000A,
/*-------------------------------------------------------*/
/* Offset=0x0001 offsetToFormatArray */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0002 offsetToMapCellArray */
0x0007,
/*-------------------------------------------------------*/
/* Offset=0x0003 offsetToMappingTable */
0x0025,
/*-------------------------------------------------------*/
/* Offset=0x0004 Start of Format Array */
/* Total of Format 0 : 0x0004 */
/* Total of Format 1 : 0x0003 */
/* Total of Format 2 : 0x0003 */
/* Total of Format 3 : 0x0000 */
0x0000, 0x1121, 0x0022,
/*-------------------------------------------------------*/
/* Offset=0x0007 Start of MapCell Array */
/* 0000 */ 0x0000, 0x007F, 0x0000,
/* 0001 */ 0x00A3, 0x00A9, 0x00A3,
/* 0002 */ 0x038E, 0x03A1, 0x00BE,
/* 0003 */ 0x03A3, 0x03CE, 0x00D3,
/* 0004 */ 0x00A0, 0x00BD, 0x0000,
/* 0005 */ 0x0192, 0x0000, 0x0083,
/* 0006 */ 0x0384, 0x038C, 0x001E,
/* 0007 */ 0x2013, 0x203A, 0x0027,
/* 0008 */ 0x20AC, 0x0000, 0x0080,
/* 0009 */ 0x2122, 0x0000, 0x0099,
/*-------------------------------------------------------*/
/* Offset=0x0025 Start of MappingTable */
/* 0000 */ 0x00A0, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0008 */ 0xFFFD, 0xFFFD, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0xFFFD,
/* 0010 */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0xFFFD, 0x00B5, 0x00B6, 0x00B7,
/* 0018 */ 0xFFFD, 0xFFFD, 0xFFFD, 0x00BB, 0xFFFD, 0x00BD, 0x00B4, 0x00A1,
/* 0020 */ 0x00A2, 0xFFFD, 0x00B8, 0x00B9, 0x00BA, 0xFFFD, 0x00BC, 0x0096,
/* 0028 */ 0x0097, 0x00AF, 0xFFFD, 0xFFFD, 0x0091, 0x0092, 0x0082, 0xFFFD,
/* 0030 */ 0x0093, 0x0094, 0x0084, 0xFFFD, 0x0086, 0x0087, 0x0095, 0xFFFD,
/* 0038 */ 0xFFFD, 0xFFFD, 0x0085, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0040 */ 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0089, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0048 */ 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x008B, 0x009B,
/* End of table Total Length = 0x0074 * 2 */

Просмотреть файл

@ -0,0 +1,109 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*========================================================
This is a Generated file. Please don't edit it.
The tool which used to generate this file is called fromu.
If you have any problem of this file. Please contact
Netscape Client International Team or
ftang@netscape <Frank Tang>
Table in Debug form
Begin of Item 0000
Format 0
srcBegin = 0000
srcEnd = 007F
destBegin = 0000
End of Item 0000
Begin of Item 0001
Format 0
srcBegin = 00A3
srcEnd = 00A9
destBegin = 00A3
End of Item 0001
Begin of Item 0002
Format 0
srcBegin = 00BE
srcEnd = 00D1
destBegin = 038E
End of Item 0002
Begin of Item 0003
Format 0
srcBegin = 00D3
srcEnd = 00FE
destBegin = 03A3
End of Item 0003
Begin of Item 0004
Format 1
srcBegin = 0080
srcEnd = 00BD
mappingOffset = 0000
Mapping =
20AC FFFD 201A 0192 201E 2026 2020 2021
FFFD 2030 FFFD 2039 FFFD FFFD FFFD FFFD
FFFD 2018 2019 201C 201D 2022 2013 2014
FFFD 2122 FFFD 203A FFFD FFFD FFFD FFFD
00A0 0385 0386 FFFD FFFD FFFD FFFD FFFD
FFFD FFFD FFFD 00AB 00AC 00AD 00AE 2015
00B0 00B1 00B2 00B3 0384 00B5 00B6 00B7
0388 0389 038A 00BB 038C 00BD
End of Item 0004
========================================================*/
/* Offset=0x0000 ItemOfList */
0x0005,
/*-------------------------------------------------------*/
/* Offset=0x0001 offsetToFormatArray */
0x0004,
/*-------------------------------------------------------*/
/* Offset=0x0002 offsetToMapCellArray */
0x0006,
/*-------------------------------------------------------*/
/* Offset=0x0003 offsetToMappingTable */
0x0015,
/*-------------------------------------------------------*/
/* Offset=0x0004 Start of Format Array */
/* Total of Format 0 : 0x0004 */
/* Total of Format 1 : 0x0001 */
/* Total of Format 2 : 0x0000 */
/* Total of Format 3 : 0x0000 */
0x0000, 0x0001,
/*-------------------------------------------------------*/
/* Offset=0x0006 Start of MapCell Array */
/* 0000 */ 0x0000, 0x007F, 0x0000,
/* 0001 */ 0x00A3, 0x00A9, 0x00A3,
/* 0002 */ 0x00BE, 0x00D1, 0x038E,
/* 0003 */ 0x00D3, 0x00FE, 0x03A3,
/* 0004 */ 0x0080, 0x00BD, 0x0000,
/*-------------------------------------------------------*/
/* Offset=0x0015 Start of MappingTable */
/* 0000 */ 0x20AC, 0xFFFD, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
/* 0008 */ 0xFFFD, 0x2030, 0xFFFD, 0x2039, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0010 */ 0xFFFD, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
/* 0018 */ 0xFFFD, 0x2122, 0xFFFD, 0x203A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0020 */ 0x00A0, 0x0385, 0x0386, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
/* 0028 */ 0xFFFD, 0xFFFD, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
/* 0030 */ 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
/* 0038 */ 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD,
/* End of table Total Length = 0x0053 * 2 */

Просмотреть файл

@ -0,0 +1,74 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
DEFINES=-D_IMPL_NS_INTL -DWIN32_LEAN_AND_MEAN
MODULE=ucvlatin
REQUIRES=xpcom uconv
MAKE_OBJ_TYPE = DLL
DLLNAME = ucvlatin
DLL=.\$(OBJDIR)\$(DLLNAME).dll
CPPSRCS = \
nsLatin1ToUnicode.cpp \
nsISO88597ToUnicode.cpp \
nsCP1253ToUnicode.cpp \
ns1ByteToUnicodeBase.cpp \
nsUCvLatinDll.cpp \
$(NULL)
CPP_OBJS= \
.\$(OBJDIR)\nsLatin1ToUnicode.obj \
.\$(OBJDIR)\nsISO88597ToUnicode.obj \
.\$(OBJDIR)\nsCP1253ToUnicode.obj \
.\$(OBJDIR)\ns1ByteToUnicodeBase.obj \
.\$(OBJDIR)\nsUCvLatinDll.obj \
$(NULL)
EXPORTS= \
$(NULL)
LINCS= \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\uconv \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\raptorbase.lib \
$(LIBNSPR)
MISCDEP = $(LLIBS)
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\layout\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
clobber::
rm -f $(DIST)\bin\$(DLLNAME).dll
rm -f $(DIST)\bin\$(DLLNAME).lib

Просмотреть файл

@ -0,0 +1,105 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "pratom.h"
#include "nsRepository.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
#include "nsICharsetConverterManager.h"
#include "ns1ByteToUnicodeBase.h"
ns1ByteToUnicodeBase::ns1ByteToUnicodeBase()
{
mUtil = nsnull;
}
ns1ByteToUnicodeBase::~ns1ByteToUnicodeBase()
{
NS_IF_RELEASE(mUtil);
}
NS_IMETHODIMP ns1ByteToUnicodeBase::Convert(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength,
const char * aSrc, PRInt32 aSrcOffset,
PRInt32 * aSrcLength)
{
if (aDest == NULL) return NS_ERROR_NULL_POINTER;
if(nsnull == mUtil)
{
nsresult res = NS_OK;
res = nsRepository::CreateInstance(
kCharsetConverterManagerCID,
NULL,
kIUnicodeDecodeUtilIID,
(void**) & mUtil);
if(NS_FAILED(res))
{
*aSrcLength = 0;
*aDestLength = 0;
return res;
}
if( PR_FALSE == GetFastTableInitState())
{
res = mUtil->Init1ByteFastTable(
this->GetMappingTable(),
this->GetFastTable());
if(NS_FAILED(res))
{
*aSrcLength = 0;
*aDestLength = 0;
return res;
}
this->SetFastTableInit();
}
}
return mUtil->Convert( aDest, aDestOffset, aDestLength,
aSrc, aSrcOffset, aSrcLength,
this->GetFastTable());
}
NS_IMETHODIMP ns1ByteToUnicodeBase::Finish(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength)
{
// it is really only a stateless converter...
*aDestLength = 0;
return NS_OK;
}
NS_IMETHODIMP ns1ByteToUnicodeBase::Length(const char * aSrc, PRInt32 aSrcOffset,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
*aDestLength = aSrcLength;
return NS_EXACT_LENGTH;
}
NS_IMETHODIMP ns1ByteToUnicodeBase::Reset()
{
return NS_OK;
}
NS_IMETHODIMP ns1ByteToUnicodeBase::SetInputErrorBehavior(PRInt32 aBehavior)
{
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef ns1ByteToUnicodeBase_h__
#define ns1ByteToUnicodeBase_h__
#include "nsRepository.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
class ns1ByteToUnicodeBase : public nsIUnicodeDecoder
{
public:
/**
* Class constructor.
*/
ns1ByteToUnicodeBase();
/**
* Class destructor.
*/
~ns1ByteToUnicodeBase();
//--------------------------------------------------------------------
// Interface nsIUnicodeDecoder [declaration]
NS_IMETHOD Convert(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength,const char * aSrc, PRInt32 aSrcOffset,
PRInt32 * aSrcLength);
NS_IMETHOD Finish(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength);
NS_IMETHOD Length(const char * aSrc, PRInt32 aSrcOffset, PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
NS_IMETHOD SetInputErrorBehavior(PRInt32 aBehavior);
private:
nsIUnicodeDecodeUtil *mUtil;
protected:
virtual uMappingTable* GetMappingTable() = 0;
virtual PRUnichar* GetFastTable() = 0;
virtual PRBool GetFastTableInitState() = 0;
virtual void SetFastTableInit() = 0;
};
#endif

Просмотреть файл

@ -0,0 +1,200 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "pratom.h"
#include "nsRepository.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
#include "nsCP1253ToUnicode.h"
#include "nsICharsetConverterManager.h"
#include "ns1ByteToUnicodeBase.h"
#include "nsUCvLatinDll.h"
#include "nsUCvLatinCID.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
#define NS_SRC_CHARSET "windows-1253"
#define NS_DEST_CHARSET "Unicode"
//----------------------------------------------------------------------
// Class nsCP1253ToUnicode [declaration]
class nsCP1253ToUnicode : public ns1ByteToUnicodeBase
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsCP1253ToUnicode();
/**
* Class destructor.
*/
~nsCP1253ToUnicode();
protected:
virtual uMappingTable* GetMappingTable();
virtual PRUnichar* GetFastTable();
virtual PRBool GetFastTableInitState();
virtual void SetFastTableInit();
};
static PRUint16 gMappingTable[] = {
#include "cp1253.ut"
};
static PRBool gFastTableInit = PR_FALSE;
static PRUnichar gFastTable[256];
//----------------------------------------------------------------------
// Class nsCP1253ToUnicode [implementation]
NS_IMPL_ISUPPORTS(nsCP1253ToUnicode, kIUnicodeDecoderIID);
nsCP1253ToUnicode::nsCP1253ToUnicode()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsCP1253ToUnicode::~nsCP1253ToUnicode()
{
PR_AtomicDecrement(&g_InstanceCount);
}
uMappingTable* nsCP1253ToUnicode::GetMappingTable()
{
return (uMappingTable*) &gMappingTable;
}
PRUnichar * nsCP1253ToUnicode::GetFastTable()
{
return gFastTable;
}
PRBool nsCP1253ToUnicode::GetFastTableInitState()
{
return gFastTableInit;
}
void nsCP1253ToUnicode::SetFastTableInit()
{
gFastTableInit = PR_TRUE;
}
//----------------------------------------------------------------------
// Class nsCP1253ToUnicodeFactory [implementation]
nsCP1253ToUnicodeFactory::nsCP1253ToUnicodeFactory()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsCP1253ToUnicodeFactory::~nsCP1253ToUnicodeFactory()
{
PR_AtomicDecrement(&g_InstanceCount);
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsCP1253ToUnicodeFactory);
NS_IMPL_RELEASE(nsCP1253ToUnicodeFactory);
nsresult nsCP1253ToUnicodeFactory::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, kICharsetConverterInfoIID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
if (aIID.Equals(kClassIID)) {
*aInstancePtr = (void*) ((nsICharsetConverterInfo*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = (void*) ((nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//----------------------------------------------------------------------
// Interface nsIFactory [implementation]
NS_IMETHODIMP nsCP1253ToUnicodeFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
nsIUnicodeDecoder * t = new nsCP1253ToUnicode;
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
nsresult res = t->QueryInterface(aIID, aResult);
if (NS_FAILED(res)) delete t;
return res;
}
NS_IMETHODIMP nsCP1253ToUnicodeFactory::LockFactory(PRBool aLock)
{
if (aLock) PR_AtomicIncrement(&g_LockCount);
else PR_AtomicDecrement(&g_LockCount);
return NS_OK;
}
//----------------------------------------------------------------------
// Interface nsICharsetConverterInfo [implementation]
NS_IMETHODIMP nsCP1253ToUnicodeFactory::GetCharsetSrc(char ** aCharset)
{
(*aCharset) = NS_SRC_CHARSET;
return NS_OK;
}
NS_IMETHODIMP nsCP1253ToUnicodeFactory::GetCharsetDest(char ** aCharset)
{
(*aCharset) = NS_DEST_CHARSET;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsCP1253ToUnicode_h___
#define nsCP1253ToUnicode_h___
#include "nsIFactory.h"
#include "nsICharsetConverterInfo.h"
//----------------------------------------------------------------------
// Class nsCP1253ToUnicodeFactory [declaration]
/**
* Factory class for the nsCP1253ToUnicode objects.
*
*/
class nsCP1253ToUnicodeFactory : public nsIFactory, nsICharsetConverterInfo
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsCP1253ToUnicodeFactory();
/**
* Class destructor.
*/
~nsCP1253ToUnicodeFactory();
//--------------------------------------------------------------------
// Interface nsIFactory [declaration]
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//--------------------------------------------------------------------
// Interface nsICharsetConverterInfo [declaration]
NS_IMETHOD GetCharsetSrc(char ** aCharset);
NS_IMETHOD GetCharsetDest(char ** aCharset);
};
#endif

Просмотреть файл

@ -0,0 +1,199 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "pratom.h"
#include "nsRepository.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
#include "nsISO88597ToUnicode.h"
#include "nsICharsetConverterManager.h"
#include "ns1ByteToUnicodeBase.h"
#include "nsUCvLatinDll.h"
#include "nsUCvLatinCID.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
#define NS_SRC_CHARSET "ISO-8859-7"
#define NS_DEST_CHARSET "Unicode"
//----------------------------------------------------------------------
// Class nsISO88597ToUnicode [declaration]
class nsISO88597ToUnicode : public ns1ByteToUnicodeBase
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsISO88597ToUnicode();
/**
* Class destructor.
*/
~nsISO88597ToUnicode();
protected:
virtual uMappingTable* GetMappingTable();
virtual PRUnichar* GetFastTable();
virtual PRBool GetFastTableInitState();
virtual void SetFastTableInit();
};
static PRUint16 gMappingTable[] = {
#include "8859-7.ut"
};
static PRBool gFastTableInit = PR_FALSE;
static PRUnichar gFastTable [256] ;
//----------------------------------------------------------------------
// Class nsISO88597ToUnicode [implementation]
NS_IMPL_ISUPPORTS(nsISO88597ToUnicode, kIUnicodeDecoderIID);
nsISO88597ToUnicode::nsISO88597ToUnicode()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsISO88597ToUnicode::~nsISO88597ToUnicode()
{
PR_AtomicDecrement(&g_InstanceCount);
}
uMappingTable* nsISO88597ToUnicode::GetMappingTable()
{
return (uMappingTable*) &gMappingTable;
}
PRUnichar * nsISO88597ToUnicode::GetFastTable()
{
return gFastTable;
}
PRBool nsISO88597ToUnicode::GetFastTableInitState()
{
return gFastTableInit;
}
void nsISO88597ToUnicode::SetFastTableInit()
{
gFastTableInit = PR_TRUE;
}
//----------------------------------------------------------------------
// Class nsISO88597ToUnicodeFactory [implementation]
nsISO88597ToUnicodeFactory::nsISO88597ToUnicodeFactory()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsISO88597ToUnicodeFactory::~nsISO88597ToUnicodeFactory()
{
PR_AtomicDecrement(&g_InstanceCount);
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsISO88597ToUnicodeFactory);
NS_IMPL_RELEASE(nsISO88597ToUnicodeFactory);
nsresult nsISO88597ToUnicodeFactory::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, kICharsetConverterInfoIID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
if (aIID.Equals(kClassIID)) {
*aInstancePtr = (void*) ((nsICharsetConverterInfo*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = (void*) ((nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//----------------------------------------------------------------------
// Interface nsIFactory [implementation]
NS_IMETHODIMP nsISO88597ToUnicodeFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
nsIUnicodeDecoder * t = new nsISO88597ToUnicode;
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
nsresult res = t->QueryInterface(aIID, aResult);
if (NS_FAILED(res)) delete t;
return res;
}
NS_IMETHODIMP nsISO88597ToUnicodeFactory::LockFactory(PRBool aLock)
{
if (aLock) PR_AtomicIncrement(&g_LockCount);
else PR_AtomicDecrement(&g_LockCount);
return NS_OK;
}
//----------------------------------------------------------------------
// Interface nsICharsetConverterInfo [implementation]
NS_IMETHODIMP nsISO88597ToUnicodeFactory::GetCharsetSrc(char ** aCharset)
{
(*aCharset) = NS_SRC_CHARSET;
return NS_OK;
}
NS_IMETHODIMP nsISO88597ToUnicodeFactory::GetCharsetDest(char ** aCharset)
{
(*aCharset) = NS_DEST_CHARSET;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsISO88597ToUnicode_h___
#define nsISO88597ToUnicode_h___
#include "nsIFactory.h"
#include "nsICharsetConverterInfo.h"
//----------------------------------------------------------------------
// Class nsISO88597ToUnicodeFactory [declaration]
/**
* Factory class for the nsISO88597ToUnicode objects.
*
*/
class nsISO88597ToUnicodeFactory : public nsIFactory, nsICharsetConverterInfo
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsISO88597ToUnicodeFactory();
/**
* Class destructor.
*/
~nsISO88597ToUnicodeFactory();
//--------------------------------------------------------------------
// Interface nsIFactory [declaration]
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//--------------------------------------------------------------------
// Interface nsICharsetConverterInfo [declaration]
NS_IMETHOD GetCharsetSrc(char ** aCharset);
NS_IMETHOD GetCharsetDest(char ** aCharset);
};
#endif

Просмотреть файл

@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "pratom.h"
#include "nsIUnicodeDecoder.h"
#include "nsLatin1ToUnicode.h"
#include "nsConverterCID.h"
#include "nsUCvLatinDll.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
#define NS_SRC_CHARSET "ISO-8859-1"
#define NS_DEST_CHARSET "Unicode"
//----------------------------------------------------------------------
// Class nsLatin1ToUnicode [declaration]
/**
* A character set converter from Latin1 to Unicode.
*
* This particular converter does not use the general single-byte converter
* helper object. That is because someone may want to optimise this converter
* to the fullest, as it is one of the most heavily used.
*
* Multithreading: not an issue, the object has one instance per user thread.
* As a plus, it is also stateless!
*
* @created 23/Nov/1998
* @author Catalin Rotaru [CATA]
*/
class nsLatin1ToUnicode : public nsIUnicodeDecoder
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsLatin1ToUnicode();
/**
* Class destructor.
*/
~nsLatin1ToUnicode();
//--------------------------------------------------------------------
// Interface nsIUnicodeDecoder [declaration]
NS_IMETHOD Convert(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength,const char * aSrc, PRInt32 aSrcOffset,
PRInt32 * aSrcLength);
NS_IMETHOD Finish(PRUnichar * aDest, PRInt32 aDestOffset,
PRInt32 * aDestLength);
NS_IMETHOD Length(const char * aSrc, PRInt32 aSrcOffset, PRInt32 aSrcLength,
PRInt32 * aDestLength);
NS_IMETHOD Reset();
NS_IMETHOD SetInputErrorBehavior(PRInt32 aBehavior);
};
//----------------------------------------------------------------------
// Class nsLatin1ToUnicode [implementation]
NS_IMPL_ISUPPORTS(nsLatin1ToUnicode, kIUnicodeDecoderIID);
nsLatin1ToUnicode::nsLatin1ToUnicode()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsLatin1ToUnicode::~nsLatin1ToUnicode()
{
PR_AtomicDecrement(&g_InstanceCount);
}
//----------------------------------------------------------------------
// Interface nsICharsetConverter [implementation]
NS_IMETHODIMP nsLatin1ToUnicode::Convert(PRUnichar * aDest,
PRInt32 aDestOffset,
PRInt32 * aDestLength,
const char * aSrc,
PRInt32 aSrcOffset,
PRInt32 * aSrcLength)
{
if (aDest == NULL) return NS_ERROR_NULL_POINTER;
PRInt32 len = PR_MIN(*aSrcLength, *aDestLength);
for (PRInt32 i=0; i<len; i++) *aDest++ = ((PRUint8)*aSrc++);
nsresult res = (*aSrcLength > len)? NS_PARTIAL_MORE_OUTPUT : NS_OK;
*aSrcLength = *aDestLength = len;
return res;
}
NS_IMETHODIMP nsLatin1ToUnicode::Finish(PRUnichar * aDest,
PRInt32 aDestOffset,
PRInt32 * aDestLength)
{
// it is really only a stateless converter...
return NS_OK;
}
NS_IMETHODIMP nsLatin1ToUnicode::Length(const char * aSrc,
PRInt32 aSrcOffset,
PRInt32 aSrcLength,
PRInt32 * aDestLength)
{
// we are a single byte to Unicode converter, so...
*aDestLength = aSrcLength;
return NS_EXACT_LENGTH;
}
NS_IMETHODIMP nsLatin1ToUnicode::Reset()
{
return NS_OK;
}
NS_IMETHODIMP nsLatin1ToUnicode::SetInputErrorBehavior(PRInt32 aBehavior)
{
// no input error possible, this encoding is too simple
return NS_OK;
}
//----------------------------------------------------------------------
// Class nsLatin1ToUnicodeFactory [implementation]
nsLatin1ToUnicodeFactory::nsLatin1ToUnicodeFactory()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsLatin1ToUnicodeFactory::~nsLatin1ToUnicodeFactory()
{
PR_AtomicDecrement(&g_InstanceCount);
}
//----------------------------------------------------------------------
// Interface nsISupports [implementation]
NS_IMPL_ADDREF(nsLatin1ToUnicodeFactory);
NS_IMPL_RELEASE(nsLatin1ToUnicodeFactory);
nsresult nsLatin1ToUnicodeFactory::QueryInterface(REFNSIID aIID,
void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
*aInstancePtr = NULL;
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kClassIID, kICharsetConverterInfoIID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
if (aIID.Equals(kClassIID)) {
*aInstancePtr = (void*) ((nsICharsetConverterInfo*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = (void*) ((nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*) ((nsISupports*)(nsIFactory*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
//----------------------------------------------------------------------
// Interface nsIFactory [implementation]
NS_IMETHODIMP nsLatin1ToUnicodeFactory::CreateInstance(nsISupports *aDelegate,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
nsIUnicodeDecoder * t = new nsLatin1ToUnicode;
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
nsresult res = t->QueryInterface(aIID, aResult);
if (NS_FAILED(res)) delete t;
return res;
}
NS_IMETHODIMP nsLatin1ToUnicodeFactory::LockFactory(PRBool aLock)
{
if (aLock) PR_AtomicIncrement(&g_LockCount);
else PR_AtomicDecrement(&g_LockCount);
return NS_OK;
}
//----------------------------------------------------------------------
// Interface nsICharsetConverterInfo [implementation]
NS_IMETHODIMP nsLatin1ToUnicodeFactory::GetCharsetSrc(char ** aCharset)
{
(*aCharset) = NS_SRC_CHARSET;
return NS_OK;
}
NS_IMETHODIMP nsLatin1ToUnicodeFactory::GetCharsetDest(char ** aCharset)
{
(*aCharset) = NS_DEST_CHARSET;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,68 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsLatin1ToUnicode_h___
#define nsLatin1ToUnicode_h___
#include "nsIFactory.h"
#include "nsICharsetConverterInfo.h"
//----------------------------------------------------------------------
// Class nsLatin1ToUnicodeFactory [declaration]
/**
* Factory class for the nsLatin1ToUnicode objects.
*
* @created 08/Dec/1998
* @author Catalin Rotaru [CATA]
*/
class nsLatin1ToUnicodeFactory : public nsIFactory, nsICharsetConverterInfo
{
NS_DECL_ISUPPORTS
public:
/**
* Class constructor.
*/
nsLatin1ToUnicodeFactory();
/**
* Class destructor.
*/
~nsLatin1ToUnicodeFactory();
//--------------------------------------------------------------------
// Interface nsIFactory [declaration]
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//--------------------------------------------------------------------
// Interface nsICharsetConverterInfo [declaration]
NS_IMETHOD GetCharsetSrc(char ** aCharset);
NS_IMETHOD GetCharsetDest(char ** aCharset);
};
#endif /* nsLatin1ToUnicode_h___ */

Просмотреть файл

@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsUCvLatinCID_h___
#define nsUCvLatinCID_h___
#include "nsISupports.h"
// Class ID for our ISO88597ToUnicode charset converter
// {AF7A9951-AA48-11d2-B3AE-00805F8A6670}
NS_DECLARE_ID(kISO88597ToUnicodeCID,
0xaf7a9951, 0xaa48, 0x11d2, 0xb3, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
// Class ID for our CP1253ToUnicode charset converter
// {AF7A9952-AA48-11d2-B3AE-00805F8A6670}
NS_DECLARE_ID(kCP1253ToUnicodeCID,
0xaf7a9952, 0xaa48, 0x11d2, 0xb3, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
#endif /* nsUCvLatinCID_h___ */

Просмотреть файл

@ -0,0 +1,126 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#define NS_IMPL_IDS
#include "nsRepository.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsLatin1ToUnicode.h"
#include "nsISO88597ToUnicode.h"
#include "nsCP1253ToUnicode.h"
#include "nsConverterCID.h"
#include "nsUCvLatinCID.h"
// just for NS_IMPL_IDS
#include "nsIUnicodeDecodeUtil.h"
#include "nsICharsetConverterManager.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
extern "C" PRInt32 g_InstanceCount = 0;
extern "C" PRInt32 g_LockCount = 0;
//----------------------------------------------------------------------
// Global functions and data [implementation]
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
extern "C" NS_EXPORT PRBool NSCanUnload()
{
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
}
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aCID,
nsIFactory **aFactory)
{
if (aFactory == NULL) return NS_ERROR_NULL_POINTER;
// the Latin1ToUnicode converter
if (aCID.Equals(kLatin1ToUnicodeCID)) {
nsLatin1ToUnicodeFactory *factory = new nsLatin1ToUnicodeFactory();
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete factory;
}
return res;
}
// the ISO88597ToUnicode converter
if (aCID.Equals(kISO88597ToUnicodeCID)) {
nsISO88597ToUnicodeFactory *factory = new nsISO88597ToUnicodeFactory();
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete factory;
}
return res;
}
// the CP1253ToUnicode converter
if (aCID.Equals(kCP1253ToUnicodeCID)) {
nsCP1253ToUnicodeFactory *factory = new nsCP1253ToUnicodeFactory();
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
if (NS_FAILED(res)) {
*aFactory = NULL;
delete factory;
}
return res;
}
return NS_NOINTERFACE;
}
extern "C" NS_EXPORT nsresult NSRegisterSelf(const char * path)
{
nsresult res;
res = nsRepository::RegisterFactory(kLatin1ToUnicodeCID, path,
PR_TRUE, PR_TRUE);
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res;
res = nsRepository::RegisterFactory(kCP1253ToUnicodeCID, path,
PR_TRUE, PR_TRUE);
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) return res;
res = nsRepository::RegisterFactory(kISO88597ToUnicodeCID, path,
PR_TRUE, PR_TRUE);
return res;
}
extern "C" NS_EXPORT nsresult NSUnregisterSelf(const char * path)
{
nsresult res;
res = nsRepository::UnregisterFactory(kLatin1ToUnicodeCID, path);
if(NS_FAILED(res)) return res;
res = nsRepository::UnregisterFactory(kCP1253ToUnicodeCID, path);
if(NS_FAILED(res)) return res;
res = nsRepository::UnregisterFactory(kISO88597ToUnicodeCID, path);
return res;
}

Просмотреть файл

@ -0,0 +1,28 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/NPL/
*
* 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 Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#ifndef nsUCvLatinDll_h___
#define nsUCvLatinDll_h___
#include "prtypes.h"
extern "C" PRInt32 g_InstanceCount;
extern "C" PRInt32 g_LockCount;
#endif /* nsUCvLatinDll_h___ */