From 861397f47a00276fe984de0211c90a6cbadbdf5b Mon Sep 17 00:00:00 2001 From: "cata%netscape.com" Date: Mon, 19 Apr 1999 21:56:04 +0000 Subject: [PATCH] Latin1 -> ISO88591 --- intl/uconv/src/registryhack2.h | 4 +- intl/uconv/ucvlatin/Makefile.in | 4 +- intl/uconv/ucvlatin/makefile.win | 8 +-- intl/uconv/ucvlatin/nsISO88591ToUnicode.cpp | 47 +++++++++++++++++ intl/uconv/ucvlatin/nsISO88591ToUnicode.h | 49 +++++++++++++++++ intl/uconv/ucvlatin/nsUCvLatinCID.h | 8 +-- intl/uconv/ucvlatin/nsUCvLatinDll.cpp | 12 ++--- intl/uconv/ucvlatin/nsUnicodeToISO88591.cpp | 58 +++++++++++++++++++++ intl/uconv/ucvlatin/nsUnicodeToISO88591.h | 57 ++++++++++++++++++++ 9 files changed, 229 insertions(+), 18 deletions(-) create mode 100644 intl/uconv/ucvlatin/nsISO88591ToUnicode.cpp create mode 100644 intl/uconv/ucvlatin/nsISO88591ToUnicode.h create mode 100644 intl/uconv/ucvlatin/nsUnicodeToISO88591.cpp create mode 100644 intl/uconv/ucvlatin/nsUnicodeToISO88591.h diff --git a/intl/uconv/src/registryhack2.h b/intl/uconv/src/registryhack2.h index 0c3a615d14e..2f8722dca69 100644 --- a/intl/uconv/src/registryhack2.h +++ b/intl/uconv/src/registryhack2.h @@ -20,7 +20,7 @@ mDecSize = 20; mDecArray = new ConverterInfo [mDecSize]; - mDecArray[0].mCID = &kLatin1ToUnicodeCID; + mDecArray[0].mCID = &kISO88591ToUnicodeCID; mDecArray[1].mCID = &kISO88592ToUnicodeCID; mDecArray[2].mCID = &kISO88597ToUnicodeCID; mDecArray[3].mCID = &kISO88599ToUnicodeCID; @@ -46,7 +46,7 @@ mEncSize = 19; mEncArray = new ConverterInfo [mEncSize]; - mEncArray[0].mCID = &kUnicodeToLatin1CID; + mEncArray[0].mCID = &kUnicodeToISO88591CID; mEncArray[1].mCID = &kUnicodeToISO88592CID; mEncArray[2].mCID = &kUnicodeToISO88597CID; mEncArray[3].mCID = &kUnicodeToISO88599CID; diff --git a/intl/uconv/ucvlatin/Makefile.in b/intl/uconv/ucvlatin/Makefile.in index 3edb7dadbd3..a3bcb128f1b 100644 --- a/intl/uconv/ucvlatin/Makefile.in +++ b/intl/uconv/ucvlatin/Makefile.in @@ -29,7 +29,7 @@ CSRCS = \ $(NULL) CPPSRCS = \ - nsLatin1ToUnicode.cpp \ + nsISO88591ToUnicode.cpp \ nsISO88592ToUnicode.cpp \ nsISO88597ToUnicode.cpp \ nsISO88599ToUnicode.cpp \ @@ -42,7 +42,7 @@ CPPSRCS = \ nsMacGreekToUnicode.cpp \ nsMacTurkishToUnicode.cpp \ nsUTF8ToUnicode.cpp \ - nsUnicodeToLatin1.cpp \ + nsUnicodeToISO88591.cpp \ nsUnicodeToISO88592.cpp \ nsUnicodeToISO88597.cpp \ nsUnicodeToISO88599.cpp \ diff --git a/intl/uconv/ucvlatin/makefile.win b/intl/uconv/ucvlatin/makefile.win index e1c47ac63fa..03090385610 100644 --- a/intl/uconv/ucvlatin/makefile.win +++ b/intl/uconv/ucvlatin/makefile.win @@ -27,7 +27,7 @@ DLLNAME = ucvlatin DLL=.\$(OBJDIR)\$(DLLNAME).dll CPPSRCS = \ - nsLatin1ToUnicode.cpp \ + nsISO88591ToUnicode.cpp \ nsISO88592ToUnicode.cpp \ nsISO88597ToUnicode.cpp \ nsISO88599ToUnicode.cpp \ @@ -40,7 +40,7 @@ CPPSRCS = \ nsMacGreekToUnicode.cpp \ nsMacTurkishToUnicode.cpp \ nsUTF8ToUnicode.cpp \ - nsUnicodeToLatin1.cpp \ + nsUnicodeToISO88591.cpp \ nsUnicodeToISO88592.cpp \ nsUnicodeToISO88597.cpp \ nsUnicodeToISO88599.cpp \ @@ -59,7 +59,7 @@ CPPSRCS = \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsLatin1ToUnicode.obj \ + .\$(OBJDIR)\nsISO88591ToUnicode.obj \ .\$(OBJDIR)\nsISO88592ToUnicode.obj \ .\$(OBJDIR)\nsISO88597ToUnicode.obj \ .\$(OBJDIR)\nsISO88599ToUnicode.obj \ @@ -72,7 +72,7 @@ CPP_OBJS= \ .\$(OBJDIR)\nsMacGreekToUnicode.obj \ .\$(OBJDIR)\nsMacTurkishToUnicode.obj \ .\$(OBJDIR)\nsUTF8ToUnicode.obj \ - .\$(OBJDIR)\nsUnicodeToLatin1.obj \ + .\$(OBJDIR)\nsUnicodeToISO88591.obj \ .\$(OBJDIR)\nsUnicodeToISO88592.obj \ .\$(OBJDIR)\nsUnicodeToISO88597.obj \ .\$(OBJDIR)\nsUnicodeToISO88599.obj \ diff --git a/intl/uconv/ucvlatin/nsISO88591ToUnicode.cpp b/intl/uconv/ucvlatin/nsISO88591ToUnicode.cpp new file mode 100644 index 00000000000..b92e2c7d2a0 --- /dev/null +++ b/intl/uconv/ucvlatin/nsISO88591ToUnicode.cpp @@ -0,0 +1,47 @@ +/* -*- 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 "nsISO88591ToUnicode.h" + +//---------------------------------------------------------------------- +// Global functions and data [declaration] + +static PRUint16 g_utMappingTable[] = { +#include "cp1252.ut" +}; + +static PRInt16 g_utShiftTable[] = { + 0, u1ByteCharset , + ShiftCell(0,0,0,0,0,0,0,0) +}; + +//---------------------------------------------------------------------- +// Class nsISO88591ToUnicode [implementation] + +nsISO88591ToUnicode::nsISO88591ToUnicode() +: nsOneByteDecoderSupport((uShiftTable*) &g_utShiftTable, + (uMappingTable*) &g_utMappingTable) +{ +} + +nsresult nsISO88591ToUnicode::CreateInstance(nsISupports ** aResult) +{ + *aResult = new nsISO88591ToUnicode(); + return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK; +} diff --git a/intl/uconv/ucvlatin/nsISO88591ToUnicode.h b/intl/uconv/ucvlatin/nsISO88591ToUnicode.h new file mode 100644 index 00000000000..2a565a4c621 --- /dev/null +++ b/intl/uconv/ucvlatin/nsISO88591ToUnicode.h @@ -0,0 +1,49 @@ +/* -*- 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 nsISO88591ToUnicode_h___ +#define nsISO88591ToUnicode_h___ + +#include "nsUCvLatinSupport.h" + +//---------------------------------------------------------------------- +// Class nsISO88591ToUnicode [declaration] + +/** + * A character set converter from ISO88591 to Unicode. + * + * @created 23/Nov/1998 + * @author Catalin Rotaru [CATA] + */ +class nsISO88591ToUnicode : public nsOneByteDecoderSupport +{ +public: + + /** + * Class constructor. + */ + nsISO88591ToUnicode(); + + /** + * Static class constructor. + */ + static nsresult CreateInstance(nsISupports **aResult); +}; + +#endif /* nsISO88591ToUnicode_h___ */ diff --git a/intl/uconv/ucvlatin/nsUCvLatinCID.h b/intl/uconv/ucvlatin/nsUCvLatinCID.h index 2100f140c31..cc8635fab32 100644 --- a/intl/uconv/ucvlatin/nsUCvLatinCID.h +++ b/intl/uconv/ucvlatin/nsUCvLatinCID.h @@ -22,9 +22,9 @@ #include "nsISupports.h" -// Class ID for our Latin1ToUnicode charset converter +// Class ID for our ISO88591ToUnicode charset converter // {A3254CB0-8E20-11d2-8A98-00600811A836} -NS_DECLARE_ID(kLatin1ToUnicodeCID, +NS_DECLARE_ID(kISO88591ToUnicodeCID, 0xa3254cb0, 0x8e20, 0x11d2, 0x8a, 0x98, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36); // Class ID for our ISO88592ToUnicode charset converter @@ -87,9 +87,9 @@ NS_DECLARE_ID(kMacTurkishToUnicodeCID, NS_DECLARE_ID(kUTF8ToUnicodeCID, 0x5534ddc0, 0xdd96, 0x11d2, 0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36); -// Class ID for our UnicodeToLatin1 charset converter +// Class ID for our UnicodeToISO88591 charset converter // {920307B0-C6E8-11d2-8AA8-00600811A836} -NS_DECLARE_ID(kUnicodeToLatin1CID, +NS_DECLARE_ID(kUnicodeToISO88591CID, 0x920307b0, 0xc6e8, 0x11d2, 0x8a, 0xa8, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36); // Class ID for our UnicodeToISO88592 charset converter diff --git a/intl/uconv/ucvlatin/nsUCvLatinDll.cpp b/intl/uconv/ucvlatin/nsUCvLatinDll.cpp index a3709ae4d0a..fa2cab7642d 100644 --- a/intl/uconv/ucvlatin/nsUCvLatinDll.cpp +++ b/intl/uconv/ucvlatin/nsUCvLatinDll.cpp @@ -27,7 +27,7 @@ #include "nsICharsetConverterInfo.h" #include "nsUCvLatinCID.h" #include "nsUCvLatinDll.h" -#include "nsLatin1ToUnicode.h" +#include "nsISO88591ToUnicode.h" #include "nsISO88592ToUnicode.h" #include "nsISO88597ToUnicode.h" #include "nsISO88599ToUnicode.h" @@ -40,7 +40,7 @@ #include "nsMacGreekToUnicode.h" #include "nsMacTurkishToUnicode.h" #include "nsUTF8ToUnicode.h" -#include "nsUnicodeToLatin1.h" +#include "nsUnicodeToISO88591.h" #include "nsUnicodeToISO88592.h" #include "nsUnicodeToISO88597.h" #include "nsUnicodeToISO88599.h" @@ -85,8 +85,8 @@ struct FactoryData FactoryData g_FactoryData[] = { { - &kLatin1ToUnicodeCID, - nsLatin1ToUnicode::CreateInstance, + &kISO88591ToUnicodeCID, + nsISO88591ToUnicode::CreateInstance, "ISO-8859-1", "Unicode" }, @@ -163,8 +163,8 @@ FactoryData g_FactoryData[] = "Unicode" }, { - &kUnicodeToLatin1CID, - nsUnicodeToLatin1::CreateInstance, + &kUnicodeToISO88591CID, + nsUnicodeToISO88591::CreateInstance, "Unicode", "ISO-8859-1" }, diff --git a/intl/uconv/ucvlatin/nsUnicodeToISO88591.cpp b/intl/uconv/ucvlatin/nsUnicodeToISO88591.cpp new file mode 100644 index 00000000000..ac5e0f41748 --- /dev/null +++ b/intl/uconv/ucvlatin/nsUnicodeToISO88591.cpp @@ -0,0 +1,58 @@ +/* -*- 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 "nsUnicodeToISO88591.h" + +//---------------------------------------------------------------------- +// Global functions and data [declaration] + +static PRUint16 g_ufMappingTable[] = { +#include "8859-1.uf" +}; + +static PRInt16 g_ufShiftTable[] = { + 0, u1ByteCharset , + ShiftCell(0,0,0,0,0,0,0,0) +}; + +//---------------------------------------------------------------------- +// Class nsUnicodeToISO88591 [implementation] + +nsUnicodeToISO88591::nsUnicodeToISO88591() +: nsTableEncoderSupport((uShiftTable*) &g_ufShiftTable, + (uMappingTable*) &g_ufMappingTable) +{ +} + +nsresult nsUnicodeToISO88591::CreateInstance(nsISupports ** aResult) +{ + *aResult = new nsUnicodeToISO88591(); + return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK; +} + +//---------------------------------------------------------------------- +// Subclassing of nsTableEncoderSupport class [implementation] + +NS_IMETHODIMP nsUnicodeToISO88591::GetMaxLength(const PRUnichar * aSrc, + PRInt32 aSrcLength, + PRInt32 * aDestLength) +{ + *aDestLength = aSrcLength; + return NS_OK_UENC_EXACTLENGTH; +} diff --git a/intl/uconv/ucvlatin/nsUnicodeToISO88591.h b/intl/uconv/ucvlatin/nsUnicodeToISO88591.h new file mode 100644 index 00000000000..ce4b28d58e8 --- /dev/null +++ b/intl/uconv/ucvlatin/nsUnicodeToISO88591.h @@ -0,0 +1,57 @@ +/* -*- 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 nsUnicodeToISO88591_h___ +#define nsUnicodeToISO88591_h___ + +#include "nsUCvLatinSupport.h" + +//---------------------------------------------------------------------- +// Class nsUnicodeToISO88591 [declaration] + +/** + * A character set converter from Unicode to ISO88591. + * + * @created 17/Feb/1999 + * @author Catalin Rotaru [CATA] + */ +class nsUnicodeToISO88591 : public nsTableEncoderSupport +{ +public: + + /** + * Class constructor. + */ + nsUnicodeToISO88591(); + + /** + * Static class constructor. + */ + static nsresult CreateInstance(nsISupports **aResult); + +protected: + + //-------------------------------------------------------------------- + // Subclassing of nsEncoderSupport class [declaration] + + NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, PRInt32 aSrcLength, + PRInt32 * aDestLength); +}; + +#endif /* nsUnicodeToISO88591_h___ */