This commit is contained in:
rickg%netscape.com 2000-03-12 09:23:40 +00:00
Родитель ffe78e83e5
Коммит 8c4b91906f
4 изменённых файлов: 54 добавлений и 0 удалений

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

@ -173,6 +173,32 @@ nsHTMLEntities::EntityToUnicode(const nsString& aEntity)
return -1;
}
PRInt32
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
NS_ASSERTION(gEntityToCodeTree, "no lookup table, needs addref");
if (gEntityToCodeTree) {
//this little piece of code exists because entities may or may not have the terminating ';'.
//if we see it, strip if off for this test...
PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1);
if(';'==theLastChar) {
nsCAutoString temp(aEntity);
temp.Truncate(aEntity.mLength-1);
return EntityToUnicode(temp);
}
EntityNode node(aEntity);
EntityNode* found = (EntityNode*)gEntityToCodeTree->FindItem(&node);
if (found) {
NS_ASSERTION(found->mStr.Equals(aEntity.mUStr,PR_FALSE,aEntity.mLength), "bad tree");
return found->mUnicode;
}
}
return -1;
}
const nsCString&
nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode)

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

@ -38,6 +38,7 @@ public:
* in it.
*/
static PRInt32 EntityToUnicode(const nsString& aEntity);
static PRInt32 EntityToUnicode(const nsCString& aEntity);
/**
* Translate an entity string into it's unicode value. This call

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

@ -173,6 +173,32 @@ nsHTMLEntities::EntityToUnicode(const nsString& aEntity)
return -1;
}
PRInt32
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
NS_ASSERTION(gEntityToCodeTree, "no lookup table, needs addref");
if (gEntityToCodeTree) {
//this little piece of code exists because entities may or may not have the terminating ';'.
//if we see it, strip if off for this test...
PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1);
if(';'==theLastChar) {
nsCAutoString temp(aEntity);
temp.Truncate(aEntity.mLength-1);
return EntityToUnicode(temp);
}
EntityNode node(aEntity);
EntityNode* found = (EntityNode*)gEntityToCodeTree->FindItem(&node);
if (found) {
NS_ASSERTION(found->mStr.Equals(aEntity.mUStr,PR_FALSE,aEntity.mLength), "bad tree");
return found->mUnicode;
}
}
return -1;
}
const nsCString&
nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode)

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

@ -38,6 +38,7 @@ public:
* in it.
*/
static PRInt32 EntityToUnicode(const nsString& aEntity);
static PRInt32 EntityToUnicode(const nsCString& aEntity);
/**
* Translate an entity string into it's unicode value. This call