extensions/universalchardet/src/base/nsUniversalDetector.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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