extensions/universalchardet/src/base/nsUniversalDetector.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:411de07a631c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef nsUniversalDetector_h__
7 #define nsUniversalDetector_h__
8
9 class nsCharSetProber;
10
11 #define NUM_OF_CHARSET_PROBERS 3
12
13 typedef enum {
14 ePureAscii = 0,
15 eEscAscii = 1,
16 eHighbyte = 2
17 } nsInputState;
18
19 #define NS_FILTER_CHINESE_SIMPLIFIED 0x01
20 #define NS_FILTER_CHINESE_TRADITIONAL 0x02
21 #define NS_FILTER_JAPANESE 0x04
22 #define NS_FILTER_KOREAN 0x08
23 #define NS_FILTER_NON_CJK 0x10
24 #define NS_FILTER_ALL 0x1F
25 #define NS_FILTER_CHINESE (NS_FILTER_CHINESE_SIMPLIFIED | \
26 NS_FILTER_CHINESE_TRADITIONAL)
27 #define NS_FILTER_CJK (NS_FILTER_CHINESE_SIMPLIFIED | \
28 NS_FILTER_CHINESE_TRADITIONAL | \
29 NS_FILTER_JAPANESE | \
30 NS_FILTER_KOREAN)
31
32 class nsUniversalDetector {
33 public:
34 nsUniversalDetector(uint32_t aLanguageFilter);
35 virtual ~nsUniversalDetector();
36 virtual nsresult HandleData(const char* aBuf, uint32_t aLen);
37 virtual void DataEnd(void);
38
39 protected:
40 virtual void Report(const char* aCharset) = 0;
41 virtual void Reset();
42 nsInputState mInputState;
43 bool mDone;
44 bool mInTag;
45 bool mStart;
46 bool mGotData;
47 char mLastChar;
48 const char * mDetectedCharset;
49 int32_t mBestGuess;
50 uint32_t mLanguageFilter;
51
52 nsCharSetProber *mCharSetProbers[NUM_OF_CHARSET_PROBERS];
53 nsCharSetProber *mEscCharSetProber;
54 };
55
56 #endif
57

mercurial