extensions/universalchardet/src/base/nsUniversalDetector.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial