change nsCharSetID into nsString type

This commit is contained in:
ftang%netscape.com 1999-01-25 16:05:04 +00:00
Родитель e2c5a60606
Коммит 3759b987f5
13 изменённых файлов: 41 добавлений и 59 удалений

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

@ -29,13 +29,6 @@ class nsString;
{ 0x35e40290, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/// Enumeration of character set ids.
enum nsCharSetID {
eCharSetID_IsoLatin1 = 0,
eCharSetID_UTF8,
eCharSetID_ShiftJis
// XXX more i'm sure...
};
/** Abstract unicode character input stream
* @see nsIInputStream
@ -84,7 +77,7 @@ extern NS_BASE nsresult
nsISupports* aOuter,
nsIInputStream* aStreamToWrap,
PRInt32 aBufferSize = 0,
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
nsString* aCharSet = nsnull);
/** Create a new nsB2UConverter for the given character set. When given
* nsnull, the converter for iso-latin1 to unicode is provided. If no
@ -93,6 +86,6 @@ extern NS_BASE nsresult
extern NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
nsString* aCharSet = nsnull);
#endif /* nsUnicharInputStream_h___ */

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

@ -161,13 +161,14 @@ nsresult IsoLatin1Converter::Convert(PRUnichar* aDst,
NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsCharSetID aCharSet)
nsString* aCharSet)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
if (eCharSetID_IsoLatin1 != aCharSet) {
return NS_BASE_STREAM_NO_CONVERTER;
// We cannot use enum to pass charset id
if ((nsnull != aCharSet) && (! aCharSet->EqualsIgnoreCase( "iso-8859-1" ))){
return NS_BASE_STREAM_NO_CONVERTER;
}
IsoLatin1Converter* it = new IsoLatin1Converter();
if (nsnull == it) {
@ -315,7 +316,7 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
nsISupports* aOuter,
nsIInputStream* aStreamToWrap,
PRInt32 aBufferSize,
nsCharSetID aCharSet)
nsString* aCharSet)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;

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

@ -23,12 +23,9 @@
#include "prprf.h"
#include "prtime.h"
static nsCharSetID ConvertCharacterSetName(const char* aName)
static nsString* ConvertCharacterSetName(const char* aName)
{
if (nsCRT::strcasecmp(aName, "iso-latin-1") == 0) {
return eCharSetID_IsoLatin1;
}
return (nsCharSetID) -1;
return new nsString(aName);
}
int main(int argc, char** argv)
@ -39,7 +36,7 @@ int main(int argc, char** argv)
}
char* characterSetName = argv[2];
nsCharSetID cset = ConvertCharacterSetName(characterSetName);
nsString* cset = ConvertCharacterSetName(characterSetName);
if (PRInt32(cset) < 0) {
printf("illegal character set name: '%s'\n", characterSetName);
return -1;

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

@ -109,8 +109,8 @@ public:
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
virtual nsCharSetID GetDocumentCharacterSet() const = 0;
virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID) = 0;
virtual nsString* GetDocumentCharacterSet() const = 0;
virtual void SetDocumentCharacterSet(nsString* aCharSetID) = 0;
/**
* Access HTTP header data (this may also get set from other sources, like

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

@ -410,7 +410,7 @@ nsDocument::nsDocument()
mDocumentTitle = nsnull;
mDocumentURL = nsnull;
mDocumentURLGroup = nsnull;
mCharacterSet = eCharSetID_IsoLatin1;
mCharacterSet = nsnull;
mParentDocument = nsnull;
mRootContent = nsnull;
mScriptObject = nsnull;
@ -635,12 +635,12 @@ nsDocument::GetBaseURL(nsIURL*& aURL) const
return NS_OK;
}
nsCharSetID nsDocument::GetDocumentCharacterSet() const
nsString* nsDocument::GetDocumentCharacterSet() const
{
return mCharacterSet;
}
void nsDocument::SetDocumentCharacterSet(nsCharSetID aCharSetID)
void nsDocument::SetDocumentCharacterSet(nsString* aCharSetID)
{
mCharacterSet = aCharSetID;
}

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

@ -117,8 +117,8 @@ public:
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
virtual nsCharSetID GetDocumentCharacterSet() const;
virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID);
virtual nsString* GetDocumentCharacterSet() const;
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
/**
* Access HTTP header data (this may also get set from other sources, like
@ -346,7 +346,7 @@ protected:
nsString* mDocumentTitle;
nsIURL* mDocumentURL;
nsIURLGroup* mDocumentURLGroup;
nsCharSetID mCharacterSet;
nsString* mCharacterSet;
nsIDocument* mParentDocument;
nsVoidArray mSubDocuments;
nsVoidArray mPresShells;

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

@ -109,8 +109,8 @@ public:
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
virtual nsCharSetID GetDocumentCharacterSet() const = 0;
virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID) = 0;
virtual nsString* GetDocumentCharacterSet() const = 0;
virtual void SetDocumentCharacterSet(nsString* aCharSetID) = 0;
/**
* Access HTTP header data (this may also get set from other sources, like

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

@ -410,7 +410,7 @@ nsDocument::nsDocument()
mDocumentTitle = nsnull;
mDocumentURL = nsnull;
mDocumentURLGroup = nsnull;
mCharacterSet = eCharSetID_IsoLatin1;
mCharacterSet = nsnull;
mParentDocument = nsnull;
mRootContent = nsnull;
mScriptObject = nsnull;
@ -635,12 +635,12 @@ nsDocument::GetBaseURL(nsIURL*& aURL) const
return NS_OK;
}
nsCharSetID nsDocument::GetDocumentCharacterSet() const
nsString* nsDocument::GetDocumentCharacterSet() const
{
return mCharacterSet;
}
void nsDocument::SetDocumentCharacterSet(nsCharSetID aCharSetID)
void nsDocument::SetDocumentCharacterSet(nsString* aCharSetID)
{
mCharacterSet = aCharSetID;
}

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

@ -117,8 +117,8 @@ public:
* Return a standard name for the document's character set. This will
* trigger a startDocumentLoad if necessary to answer the question.
*/
virtual nsCharSetID GetDocumentCharacterSet() const;
virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID);
virtual nsString* GetDocumentCharacterSet() const;
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
/**
* Access HTTP header data (this may also get set from other sources, like
@ -346,7 +346,7 @@ protected:
nsString* mDocumentTitle;
nsIURL* mDocumentURL;
nsIURLGroup* mDocumentURLGroup;
nsCharSetID mCharacterSet;
nsString* mCharacterSet;
nsIDocument* mParentDocument;
nsVoidArray mSubDocuments;
nsVoidArray mPresShells;

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

@ -145,9 +145,9 @@ public:
NS_IMETHOD GetBaseURL(nsIURL*& aURL) const;
virtual nsCharSetID GetDocumentCharacterSet() const;
virtual nsString* GetDocumentCharacterSet() const;
virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID);
virtual void SetDocumentCharacterSet(nsString* aCharSetID);
NS_IMETHOD GetHeaderData(nsIAtom* aHeaderField, nsString& aData) const;
NS_IMETHOD SetHeaderData(nsIAtom* aheaderField, const nsString& aData);
@ -336,7 +336,7 @@ protected:
nsIContent* mRootContent;
nsIDocument* mParentDocument;
nsIScriptContextOwner* mScriptContextOwner;
nsCharSetID mCharSetID;
nsString* mCharSetID;
nsVoidArray mStyleSheets;
nsICollection* mSelection;
PRBool mDisplaySelection;
@ -752,14 +752,14 @@ RDFDocumentImpl::GetBaseURL(nsIURL*& aURL) const
return NS_OK;
}
nsCharSetID
nsString*
RDFDocumentImpl::GetDocumentCharacterSet() const
{
return mCharSetID;
}
void
RDFDocumentImpl::SetDocumentCharacterSet(nsCharSetID aCharSetID)
RDFDocumentImpl::SetDocumentCharacterSet(nsString* aCharSetID)
{
mCharSetID = aCharSetID;
}

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

@ -29,13 +29,6 @@ class nsString;
{ 0x35e40290, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/// Enumeration of character set ids.
enum nsCharSetID {
eCharSetID_IsoLatin1 = 0,
eCharSetID_UTF8,
eCharSetID_ShiftJis
// XXX more i'm sure...
};
/** Abstract unicode character input stream
* @see nsIInputStream
@ -84,7 +77,7 @@ extern NS_BASE nsresult
nsISupports* aOuter,
nsIInputStream* aStreamToWrap,
PRInt32 aBufferSize = 0,
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
nsString* aCharSet = nsnull);
/** Create a new nsB2UConverter for the given character set. When given
* nsnull, the converter for iso-latin1 to unicode is provided. If no
@ -93,6 +86,6 @@ extern NS_BASE nsresult
extern NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsCharSetID aCharSet = eCharSetID_IsoLatin1);
nsString* aCharSet = nsnull);
#endif /* nsUnicharInputStream_h___ */

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

@ -161,13 +161,14 @@ nsresult IsoLatin1Converter::Convert(PRUnichar* aDst,
NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsCharSetID aCharSet)
nsString* aCharSet)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
if (eCharSetID_IsoLatin1 != aCharSet) {
return NS_BASE_STREAM_NO_CONVERTER;
// We cannot use enum to pass charset id
if ((nsnull != aCharSet) && (! aCharSet->EqualsIgnoreCase( "iso-8859-1" ))){
return NS_BASE_STREAM_NO_CONVERTER;
}
IsoLatin1Converter* it = new IsoLatin1Converter();
if (nsnull == it) {
@ -315,7 +316,7 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
nsISupports* aOuter,
nsIInputStream* aStreamToWrap,
PRInt32 aBufferSize,
nsCharSetID aCharSet)
nsString* aCharSet)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;

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

@ -23,12 +23,9 @@
#include "prprf.h"
#include "prtime.h"
static nsCharSetID ConvertCharacterSetName(const char* aName)
static nsString* ConvertCharacterSetName(const char* aName)
{
if (nsCRT::strcasecmp(aName, "iso-latin-1") == 0) {
return eCharSetID_IsoLatin1;
}
return (nsCharSetID) -1;
return new nsString(aName);
}
int main(int argc, char** argv)
@ -39,7 +36,7 @@ int main(int argc, char** argv)
}
char* characterSetName = argv[2];
nsCharSetID cset = ConvertCharacterSetName(characterSetName);
nsString* cset = ConvertCharacterSetName(characterSetName);
if (PRInt32(cset) < 0) {
printf("illegal character set name: '%s'\n", characterSetName);
return -1;