зеркало из https://github.com/mozilla/pjs.git
add cyrillic detector based on John Neystadt john@neystadt.org http://www.neystadt.org/john/
This commit is contained in:
Родитель
77b77c8506
Коммит
f2384726a7
|
@ -0,0 +1,73 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
#ifndef nsCyrillicClass_h__
|
||||
#define nsCyrillicClass_h__
|
||||
/* PLEASE DO NOT EDIT THIS FILE DIRECTLY. THIS FILE IS GENERATED BY
|
||||
GenCyrllicClass found in mozilla/intl/chardet/tools
|
||||
*/
|
||||
static PRUint8 KOI8Map [128] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
|
||||
};
|
||||
static PRUint8 CP1251Map [128] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
};
|
||||
static PRUint8 IBM866Map [128] = {
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static PRUint8 ISO88595Map [128] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
static PRUint8 MacCyrillicMap [128] = {
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 18,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
|
||||
2, 3, 24, 8, 5, 6, 23, 27, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 20, 21, 22, 7, 9, 4, 31, 28, 30, 32, 26, 25, 29, 1, 0,
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,356 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
#include "nscore.h"
|
||||
#include "nsCyrillicProb.h"
|
||||
#include "nsCyrillicClass.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "nsCyrillicDetector.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsIStringCharsetDetector.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
|
||||
#include "nsCharDetDll.h"
|
||||
//---- for XPCOM
|
||||
#include "nsIFactory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCharDetDll.h"
|
||||
#include "pratom.h"
|
||||
// temp fix for XPCOM should be remove after alechf fix the xpcom one
|
||||
#define MY_NS_IMPL_QUERY_INTERFACE(_class,_classiiddef,_interface) \
|
||||
NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
if (NULL == aInstancePtr) { \
|
||||
return NS_ERROR_NULL_POINTER; \
|
||||
} \
|
||||
\
|
||||
*aInstancePtr = NULL; \
|
||||
\
|
||||
static NS_DEFINE_IID(kClassIID, _classiiddef); \
|
||||
if (aIID.Equals(kClassIID)) { \
|
||||
*aInstancePtr = (void*) ((_interface*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((nsISupports*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
return NS_NOINTERFACE; \
|
||||
}
|
||||
#define MY_NS_IMPL_ISUPPORTS(_class,_classiiddef,_interface) \
|
||||
NS_IMPL_ADDREF(_class) \
|
||||
NS_IMPL_RELEASE(_class) \
|
||||
MY_NS_IMPL_QUERY_INTERFACE(_class,_classiiddef,_interface)
|
||||
|
||||
NS_DEFINE_CID(kRUProbDetectorCID, NS_RU_PROBDETECTOR_CID);
|
||||
NS_DEFINE_CID(kUKProbDetectorCID, NS_UK_PROBDETECTOR_CID);
|
||||
NS_DEFINE_CID(kRUStringProbDetectorCID, NS_RU_STRING_PROBDETECTOR_CID);
|
||||
NS_DEFINE_CID(kUKStringProbDetectorCID, NS_UK_STRING_PROBDETECTOR_CID);
|
||||
|
||||
#define NUM_CYR_CHARSET 5
|
||||
|
||||
class nsCyrillicDetector {
|
||||
public:
|
||||
nsCyrillicDetector(PRUint8 aItems,
|
||||
PRUint8 ** aCyrillicClass,
|
||||
const char **aCharsets)
|
||||
{
|
||||
mItems = aItems;
|
||||
mCyrillicClass = aCyrillicClass;
|
||||
mCharsets = aCharsets;
|
||||
for(PRUint8 i=0;i<mItems;i++)
|
||||
mProb[i] = mLastCls[i] =0;
|
||||
};
|
||||
virtual ~nsCyrillicDetector() {};
|
||||
virtual void HandleData(const char* aBuf, PRUint32 aLen);
|
||||
virtual void DataEnd();
|
||||
protected:
|
||||
virtual void Report(const char* aCharset) = 0;
|
||||
|
||||
private:
|
||||
PRUint8 mItems;
|
||||
PRUint8 ** mCyrillicClass;
|
||||
const char** mCharsets;
|
||||
PRUint32 mProb[NUM_CYR_CHARSET];
|
||||
PRUint8 mLastCls[NUM_CYR_CHARSET];
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void nsCyrillicDetector::HandleData(const char* aBuf, PRUint32 aLen)
|
||||
{
|
||||
PRUint8 cls;
|
||||
const char* b;
|
||||
PRUint32 i;
|
||||
for(i=0, b=aBuf;i<aLen;i++,b++)
|
||||
{
|
||||
for(PRUint8 j=0;j<mItems;j++)
|
||||
{
|
||||
cls = mCyrillicClass[j][*b];
|
||||
mProb[j] += gCyrillicProb[mLastCls[j]][cls];
|
||||
mLastCls[j] = cls;
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
void nsCyrillicDetector::DataEnd()
|
||||
{
|
||||
PRUint32 max=0;
|
||||
PRUint8 maxIdx=0;
|
||||
PRUint8 j;
|
||||
for(j=1;j<mItems;j++) {
|
||||
if(mProb[j] > max)
|
||||
{
|
||||
max = mProb[j];
|
||||
maxIdx= j;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
for(j=0;j<mItems;j++)
|
||||
printf("Charset %s->\t%d\n", mCharsets[j], mProb[j]);
|
||||
#endif
|
||||
this->Report(mCharsets[maxIdx]);
|
||||
}
|
||||
//=====================================================================
|
||||
class nsCyrXPCOMDetector :
|
||||
public nsCyrillicDetector,
|
||||
public nsICharsetDetector
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
nsCyrXPCOMDetector(PRUint8 aItems,
|
||||
PRUint8 ** aCyrillicClass,
|
||||
const char **aCharsets);
|
||||
virtual ~nsCyrXPCOMDetector();
|
||||
NS_IMETHOD Init(nsICharsetDetectionObserver* aObserver);
|
||||
NS_IMETHOD DoIt(const char* aBuf, PRUint32 aLen, PRBool *oDontFeedMe);
|
||||
NS_IMETHOD Done();
|
||||
protected:
|
||||
virtual void Report(const char* aCharset);
|
||||
private:
|
||||
nsICharsetDetectionObserver* mObserver;
|
||||
};
|
||||
//---------------------------------------------------------------------
|
||||
nsCyrXPCOMDetector:: nsCyrXPCOMDetector(PRUint8 aItems,
|
||||
PRUint8 ** aCyrillicClass,
|
||||
const char **aCharsets)
|
||||
: nsCyrillicDetector(aItems, aCyrillicClass, aCharsets)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
mObserver = nsnull;
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
nsCyrXPCOMDetector::~nsCyrXPCOMDetector()
|
||||
{
|
||||
NS_IF_RELEASE(mObserver);
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
MY_NS_IMPL_ISUPPORTS(nsCyrXPCOMDetector, nsICharsetDetector::GetIID(), nsICharsetDetector)
|
||||
//---------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsCyrXPCOMDetector::Init(
|
||||
nsICharsetDetectionObserver* aObserver)
|
||||
{
|
||||
NS_ASSERTION(mObserver == nsnull , "Init twice");
|
||||
if(nsnull == aObserver)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
NS_IF_ADDREF(aObserver);
|
||||
mObserver = aObserver;
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsCyrXPCOMDetector::DoIt(
|
||||
const char* aBuf, PRUint32 aLen, PRBool* oDontFeedMe)
|
||||
{
|
||||
NS_ASSERTION(mObserver != nsnull , "have not init yet");
|
||||
|
||||
if((nsnull == aBuf) || (nsnull == oDontFeedMe))
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
this->HandleData(aBuf, aLen);
|
||||
*oDontFeedMe = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
NS_IMETHODIMP nsCyrXPCOMDetector::Done()
|
||||
{
|
||||
NS_ASSERTION(mObserver != nsnull , "have not init yet");
|
||||
this->DataEnd();
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------
|
||||
void nsCyrXPCOMDetector::Report(const char* aCharset)
|
||||
{
|
||||
NS_ASSERTION(mObserver != nsnull , "have not init yet");
|
||||
mObserver->Notify(aCharset, eBestAnswer);
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================
|
||||
class nsCyrXPCOMStringDetector :
|
||||
public nsCyrillicDetector,
|
||||
public nsIStringCharsetDetector
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
public:
|
||||
nsCyrXPCOMStringDetector(PRUint8 aItems,
|
||||
PRUint8 ** aCyrillicClass,
|
||||
const char **aCharsets);
|
||||
virtual ~nsCyrXPCOMStringDetector();
|
||||
NS_IMETHOD DoIt(const char* aBuf, PRUint32 aLen,
|
||||
const char** oCharset, nsDetectionConfident &oConf);
|
||||
protected:
|
||||
virtual void Report(const char* aCharset);
|
||||
private:
|
||||
nsICharsetDetectionObserver* mObserver;
|
||||
const char* mResult;
|
||||
};
|
||||
//---------------------------------------------------------------------
|
||||
nsCyrXPCOMStringDetector:: nsCyrXPCOMStringDetector(PRUint8 aItems,
|
||||
PRUint8 ** aCyrillicClass,
|
||||
const char **aCharsets)
|
||||
: nsCyrillicDetector(aItems, aCyrillicClass, aCharsets)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
nsCyrXPCOMStringDetector::~nsCyrXPCOMStringDetector()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
MY_NS_IMPL_ISUPPORTS(nsCyrXPCOMStringDetector,
|
||||
nsIStringCharsetDetector::GetIID(), nsIStringCharsetDetector)
|
||||
//---------------------------------------------------------------------
|
||||
void nsCyrXPCOMStringDetector::Report(const char *aCharset)
|
||||
{
|
||||
mResult = aCharset;
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsCyrXPCOMStringDetector::DoIt(const char* aBuf, PRUint32 aLen,
|
||||
const char** oCharset, nsDetectionConfident &oConf)
|
||||
{
|
||||
mResult = nsnull;
|
||||
this->HandleData(aBuf, aLen);
|
||||
this->DataEnd();
|
||||
*oCharset=mResult;
|
||||
oConf = eBestAnswer;
|
||||
return NS_OK;
|
||||
}
|
||||
//=====================================================================
|
||||
static PRUint8 *gCyrillicCls[5] =
|
||||
{
|
||||
CP1251Map,
|
||||
KOI8Map,
|
||||
ISO88595Map,
|
||||
MacCyrillicMap,
|
||||
IBM866Map
|
||||
};
|
||||
static const char* gRussian[5] = {
|
||||
"windows-1251",
|
||||
"KOI8-R",
|
||||
"ISO-8859-5",
|
||||
"x-mac-cyrillic",
|
||||
"IBM866"
|
||||
};
|
||||
static const char* gUkrainian[5] = {
|
||||
"windows-1251",
|
||||
"KOI8-U",
|
||||
"ISO-8859-5",
|
||||
"x-mac-ukrainian",
|
||||
"IBM866"
|
||||
};
|
||||
//=====================================================================
|
||||
|
||||
class MyFactory : public nsIFactory {
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
public:
|
||||
MyFactory(const nsCID& aCID) {
|
||||
NS_INIT_REFCNT();
|
||||
mCID = aCID;
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
virtual ~MyFactory() {
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
private:
|
||||
nsCID mCID;
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------
|
||||
NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_IMPL_ISUPPORTS( MyFactory , kIFactoryIID);
|
||||
|
||||
NS_IMETHODIMP MyFactory::CreateInstance(
|
||||
nsISupports* aDelegate, const nsIID &aIID, void** aResult)
|
||||
{
|
||||
if(NULL == aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
if(NULL != aDelegate)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = NULL;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
|
||||
if (mCID.Equals(kRUProbDetectorCID)) {
|
||||
inst = new nsCyrXPCOMDetector(5, gCyrillicCls, gRussian);
|
||||
} else if (mCID.Equals(kRUStringProbDetectorCID)) {
|
||||
inst = new nsCyrXPCOMStringDetector(5, gCyrillicCls, gRussian);
|
||||
} else if (mCID.Equals(kUKProbDetectorCID)) {
|
||||
inst = new nsCyrXPCOMDetector(5, gCyrillicCls, gUkrainian);
|
||||
} else if (mCID.Equals(kUKStringProbDetectorCID)) {
|
||||
inst = new nsCyrXPCOMStringDetector(5, gCyrillicCls, gUkrainian);
|
||||
}
|
||||
if(NULL == inst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsresult res =inst->QueryInterface(aIID, aResult);
|
||||
if(NS_FAILED(res)) {
|
||||
delete inst;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
NS_IMETHODIMP MyFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if(aLock)
|
||||
PR_AtomicIncrement( &g_LockCount );
|
||||
else
|
||||
PR_AtomicDecrement( &g_LockCount );
|
||||
return NS_OK;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
nsIFactory* NEW_PROBDETECTOR_FACTORY(const nsCID& aClass) {
|
||||
return new MyFactory(aClass);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
#ifndef nsCyrillicDetector_h__
|
||||
#define nsCyrillicDetector_h__
|
||||
|
||||
|
||||
#include "nsIFactory.h"
|
||||
|
||||
|
||||
|
||||
// {2002F781-3960-11d3-B3C3-00805F8A6670}
|
||||
#define NS_RU_PROBDETECTOR_CID \
|
||||
{ 0x2002f781, 0x3960, 0x11d3, { 0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
|
||||
|
||||
|
||||
// {2002F782-3960-11d3-B3C3-00805F8A6670}
|
||||
#define NS_UK_PROBDETECTOR_CID \
|
||||
{ 0x2002f782, 0x3960, 0x11d3, { 0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
|
||||
|
||||
// {2002F783-3960-11d3-B3C3-00805F8A6670}
|
||||
#define NS_RU_STRING_PROBDETECTOR_CID \
|
||||
{ 0x2002f783, 0x3960, 0x11d3, { 0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
|
||||
|
||||
|
||||
// {2002F784-3960-11d3-B3C3-00805F8A6670}
|
||||
#define NS_UK_STRING_PROBDETECTOR_CID \
|
||||
{ 0x2002f784, 0x3960, 0x11d3, { 0xb3, 0xc3, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
|
||||
|
||||
nsIFactory* NEW_PROBDETECTOR_FACTORY(const nsCID& aClass);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,295 @@
|
|||
/* -*- 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.
|
||||
*/
|
||||
|
||||
#ifndef nsCyrillicProb_h___h__
|
||||
#define nsCyrillicProb_h___h__
|
||||
/*
|
||||
DO NOT EDIT THIS FILE !!!
|
||||
This file is generated by the perl script in
|
||||
mozilla/intl/chardet/tools/gencyrillic.pl
|
||||
|
||||
To ues that script, you need to grab StatKoi.pm file from
|
||||
the "Cyrillic Software Suite" written by John Neystdt.
|
||||
http://www.neystadt.org/cyrillic (You can also find it from CPAN)
|
||||
*/
|
||||
PRUint16 gCyrillicProb[33][33] = {{
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
1, 0, 62, 8, 237, 0, 0, 0,
|
||||
0, 0, 0, 0, 2, 0, 1, 0,
|
||||
0, 0, 50, 9, 1342, 0, 5, 10,
|
||||
0, 0, 16, 2, 0, 2041, 505, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
1197, 0, 891, 3797, 594, 2064, 112, 646,
|
||||
1039, 166, 152, 3162, 10935, 3465, 10268, 5,
|
||||
277, 1744, 3706, 5043, 8884, 79, 716, 4563,
|
||||
0, 0, 3090, 205, 9, 591, 1515, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
206, 1117, 0, 0, 0, 652, 0, 0,
|
||||
92, 194, 0, 4, 924, 25, 204, 2334,
|
||||
2, 836, 832, 403, 0, 365, 63, 1,
|
||||
0, 1257, 5, 9, 0, 358, 0, 629,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 935, 0, 0, 0, 1695, 0, 0,
|
||||
0, 5193, 0, 5, 1, 1, 0, 461,
|
||||
0, 0, 0, 0, 0, 216, 0, 9,
|
||||
0, 47, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 4049, 20, 22, 27, 8713, 0, 49,
|
||||
0, 1530, 0, 660, 1182, 138, 1459, 5347,
|
||||
1488, 344, 741, 1738, 63, 1460, 206, 242,
|
||||
19, 743, 26, 51, 0, 0, 33, 90,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
141, 635, 516, 183, 8332, 911, 108, 2694,
|
||||
255, 76, 2958, 2366, 8125, 3209, 19276, 285,
|
||||
346, 483, 6823, 5705, 6596, 45, 1286, 525,
|
||||
0, 0, 1093, 414, 15, 286, 767, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 272, 0, 0, 0, 376, 50, 0,
|
||||
0, 803, 0, 0, 15, 2, 28, 591,
|
||||
0, 0, 6, 2, 24, 19, 0, 0,
|
||||
7, 31, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 4191, 0, 0, 68, 162, 0, 0,
|
||||
0, 1248, 0, 8, 369, 0, 12, 15161,
|
||||
0, 0, 678, 0, 2, 337, 0, 0,
|
||||
0, 0, 0, 19, 0, 0, 11, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 102, 0, 0, 0, 5, 0, 15,
|
||||
0, 27, 0, 6, 2, 1, 92, 2227,
|
||||
0, 0, 101, 161, 7, 15, 0, 2,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
1245, 609, 755, 2134, 1161, 4628, 120, 151,
|
||||
2180, 5903, 3242, 2804, 3261, 4656, 3708, 1658,
|
||||
104, 7815, 882, 3354, 3398, 16, 169, 1769,
|
||||
0, 0, 5064, 96, 0, 48, 1628, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 0, 0, 0, 1, 3, 3, 0,
|
||||
0, 0, 0, 6, 0, 12, 96, 67,
|
||||
1, 0, 0, 2066, 11, 0, 0, 0,
|
||||
0, 0, 0, 20, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 4402, 0, 677, 0, 782, 0, 2,
|
||||
0, 2724, 0, 10, 876, 0, 35, 6609,
|
||||
0, 0, 651, 1323, 1558, 1049, 416, 225,
|
||||
0, 0, 2, 13, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
741, 5440, 0, 0, 1, 6066, 0, 89,
|
||||
0, 9040, 0, 153, 97, 4, 949, 9899,
|
||||
0, 2830, 0, 8, 16, 2139, 434, 0,
|
||||
7487, 157, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 2073, 13, 0, 0, 4818, 0, 0,
|
||||
0, 3684, 0, 30, 89, 1094, 204, 4078,
|
||||
119, 61, 1, 68, 0, 1684, 0, 68,
|
||||
10, 1424, 0, 0, 0, 14, 6, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
18, 16528, 0, 176, 474, 5075, 174, 31,
|
||||
0, 14151, 0, 840, 0, 0, 8956, 14457,
|
||||
0, 911, 0, 1150, 1893, 711, 8, 199,
|
||||
271, 9281, 192, 0, 0, 2, 84, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
23, 27, 4868, 799, 7820, 1391, 145, 13562,
|
||||
909, 1551, 5834, 1881, 4400, 6329, 2878, 1911,
|
||||
3632, 2374, 7308, 8626, 6679, 161, 2573, 15172,
|
||||
0, 0, 1322, 778, 34, 129, 944, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 671, 0, 12, 0, 2500, 1, 0,
|
||||
0, 409, 0, 26, 3612, 0, 38, 8786,
|
||||
268, 87, 13327, 13, 15, 471, 0, 0,
|
||||
7, 266, 0, 0, 0, 0, 2, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
847, 0, 3, 184, 878, 1070, 0, 19,
|
||||
482, 0, 90, 18, 26, 765, 151, 0,
|
||||
0, 18, 20, 81, 2587, 0, 51, 766,
|
||||
0, 0, 1224, 0, 0, 2209, 20, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
2, 10059, 62, 17, 21, 11067, 6, 2653,
|
||||
30, 7582, 0, 122, 14, 638, 490, 6767,
|
||||
9, 1045, 431, 1139, 683, 2482, 326, 496,
|
||||
156, 938, 0, 254, 0, 0, 30, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
17, 1493, 218, 3, 213, 633, 26, 3,
|
||||
590, 2176, 0, 3716, 3732, 938, 693, 4388,
|
||||
1639, 4197, 1185, 2118, 21815, 2792, 0, 1033,
|
||||
154, 239, 0, 25, 0, 0, 522, 3,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 9785, 0, 27, 197, 8202, 0, 12,
|
||||
24, 5253, 0, 433, 12, 53, 2577, 9712,
|
||||
25, 122, 3392, 4966, 4, 836, 0, 8956,
|
||||
4693, 1483, 5, 3, 0, 0, 270, 3,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
1930, 104, 260, 18, 1452, 325, 6, 1192,
|
||||
51, 6, 0, 1098, 301, 1778, 398, 0,
|
||||
2263, 7, 254, 2808, 452, 0, 743, 140,
|
||||
0, 0, 45, 559, 0, 1336, 2289, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 796, 390, 0, 1303, 3459, 1, 11,
|
||||
0, 632, 0, 37, 0, 0, 620, 0,
|
||||
15, 0, 1, 0, 0, 25, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 7418, 0, 51, 10, 5465, 0, 1,
|
||||
51, 2962, 0, 999, 3853, 82, 1048, 7277,
|
||||
241, 370, 394, 280, 286, 1126, 0, 183,
|
||||
24, 3182, 197, 286, 0, 28, 0, 4,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
395, 0, 6, 22, 0, 496, 9, 113,
|
||||
0, 700, 0, 171, 0, 78, 3296, 0,
|
||||
0, 1501, 0, 1379, 193, 0, 0, 0,
|
||||
0, 0, 487, 165, 0, 1633, 30, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 0, 36, 0, 272, 2847, 0, 27,
|
||||
4998, 1, 1192, 33, 224, 2657, 219, 0,
|
||||
363, 29, 273, 205, 503, 0, 0, 400,
|
||||
0, 0, 38, 255, 0, 0, 305, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 7005, 32, 32, 869, 400, 0, 37,
|
||||
0, 999, 0, 46, 204, 739, 1570, 1076,
|
||||
0, 112, 89, 0, 1, 430, 1, 1191,
|
||||
3, 368, 0, 0, 0, 0, 2, 77,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 200, 0, 0, 0, 2054, 0, 0,
|
||||
0, 397, 0, 19, 438, 0, 108, 0,
|
||||
0, 0, 4, 0, 112, 3, 0, 0,
|
||||
4, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 0, 0, 0, 0, 0, 29, 0,
|
||||
0, 0, 0, 311, 16, 19, 11, 0,
|
||||
2, 0, 10, 3, 1382, 0, 0, 10,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 297, 0, 0, 0, 4290, 0, 0,
|
||||
0, 3968, 0, 0, 0, 0, 33, 0,
|
||||
0, 0, 1, 0, 0, 70, 0, 0,
|
||||
15, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 2304, 0, 0, 0, 4731, 0, 0,
|
||||
0, 1873, 0, 198, 33, 0, 921, 0,
|
||||
0, 0, 191, 0, 114, 134, 0, 2,
|
||||
12, 0, 0, 7, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
{
|
||||
0,
|
||||
0, 0, 0, 0, 0, 599, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 207, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
||||
},
|
||||
};
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче