Line data Source code
1 : /* -*- Mode: C; tab-width: 4; 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 :
7 : #include "nsEscCharsetProber.h"
8 : #include "nsUniversalDetector.h"
9 :
10 0 : nsEscCharSetProber::nsEscCharSetProber()
11 : {
12 0 : mCodingSM = new nsCodingStateMachine(&ISO2022JPSMModel);
13 0 : mState = eDetecting;
14 0 : mDetectedCharset = nullptr;
15 0 : }
16 :
17 0 : nsEscCharSetProber::~nsEscCharSetProber(void)
18 : {
19 0 : }
20 :
21 0 : void nsEscCharSetProber::Reset(void)
22 : {
23 0 : mState = eDetecting;
24 0 : mCodingSM->Reset();
25 0 : mDetectedCharset = nullptr;
26 0 : }
27 :
28 0 : nsProbingState nsEscCharSetProber::HandleData(const char* aBuf, uint32_t aLen)
29 : {
30 : nsSMState codingState;
31 : uint32_t i;
32 :
33 0 : for ( i = 0; i < aLen && mState == eDetecting; i++)
34 : {
35 0 : codingState = mCodingSM->NextState(aBuf[i]);
36 0 : if (codingState == eItsMe)
37 : {
38 0 : mState = eFoundIt;
39 0 : mDetectedCharset = mCodingSM->GetCodingStateMachine();
40 0 : return mState;
41 : }
42 : }
43 :
44 0 : return mState;
45 : }
46 :
|