extensions/universalchardet/src/base/nsUniversalDetector.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/universalchardet/src/base/nsUniversalDetector.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsUniversalDetector_h__
    1.10 +#define nsUniversalDetector_h__
    1.11 +
    1.12 +class nsCharSetProber;
    1.13 +
    1.14 +#define NUM_OF_CHARSET_PROBERS  3
    1.15 +
    1.16 +typedef enum {
    1.17 +  ePureAscii = 0,
    1.18 +  eEscAscii  = 1,
    1.19 +  eHighbyte  = 2
    1.20 +} nsInputState;
    1.21 +
    1.22 +#define NS_FILTER_CHINESE_SIMPLIFIED  0x01
    1.23 +#define NS_FILTER_CHINESE_TRADITIONAL 0x02
    1.24 +#define NS_FILTER_JAPANESE            0x04
    1.25 +#define NS_FILTER_KOREAN              0x08
    1.26 +#define NS_FILTER_NON_CJK             0x10
    1.27 +#define NS_FILTER_ALL                 0x1F
    1.28 +#define NS_FILTER_CHINESE (NS_FILTER_CHINESE_SIMPLIFIED | \
    1.29 +                           NS_FILTER_CHINESE_TRADITIONAL)
    1.30 +#define NS_FILTER_CJK (NS_FILTER_CHINESE_SIMPLIFIED | \
    1.31 +                       NS_FILTER_CHINESE_TRADITIONAL | \
    1.32 +                       NS_FILTER_JAPANESE | \
    1.33 +                       NS_FILTER_KOREAN)
    1.34 +
    1.35 +class nsUniversalDetector {
    1.36 +public:
    1.37 +   nsUniversalDetector(uint32_t aLanguageFilter);
    1.38 +   virtual ~nsUniversalDetector();
    1.39 +   virtual nsresult HandleData(const char* aBuf, uint32_t aLen);
    1.40 +   virtual void DataEnd(void);
    1.41 +
    1.42 +protected:
    1.43 +   virtual void Report(const char* aCharset) = 0;
    1.44 +   virtual void Reset();
    1.45 +   nsInputState  mInputState;
    1.46 +   bool    mDone;
    1.47 +   bool    mInTag;
    1.48 +   bool    mStart;
    1.49 +   bool    mGotData;
    1.50 +   char    mLastChar;
    1.51 +   const char *  mDetectedCharset;
    1.52 +   int32_t mBestGuess;
    1.53 +   uint32_t mLanguageFilter;
    1.54 +
    1.55 +   nsCharSetProber  *mCharSetProbers[NUM_OF_CHARSET_PROBERS];
    1.56 +   nsCharSetProber  *mEscCharSetProber;
    1.57 +};
    1.58 +
    1.59 +#endif
    1.60 +

mercurial