Coverage Report

Created: 2026-11-12 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/kcodecs/src/probers/nsSJISProber.h
Line
Count
Source
1
/*
2
    The Original Code is mozilla.org code.
3
4
    SPDX-FileCopyrightText: 1998 Netscape Communications Corporation
5
6
    SPDX-License-Identifier: MPL-1.1 OR GPL-2.0-or-later OR LGPL-2.1-or-later
7
*/
8
9
// for S-JIS encoding, observe characteristic:
10
// 1, kana character (or hankaku?) often have high frequency of appearance
11
// 2, kana character often exist in group
12
// 3, certain combination of kana is never used in japanese language
13
14
#ifndef nsSJISProber_h__
15
#define nsSJISProber_h__
16
17
#include "CharDistribution.h"
18
#include "JpCntx.h"
19
#include "nsCharSetProber.h"
20
#include "nsCodingStateMachine.h"
21
22
#include <memory>
23
24
namespace kencodingprober
25
{
26
class KCODECS_NO_EXPORT nsSJISProber : public nsCharSetProber
27
{
28
public:
29
    nsSJISProber();
30
25.1k
    ~nsSJISProber() override = default;
31
32
    nsProbingState HandleData(const char *aBuf, unsigned int aLen) override;
33
    const char *GetCharSetName() override
34
60
    {
35
60
        return "Shift_JIS";
36
60
    }
37
    nsProbingState GetState(void) override
38
0
    {
39
0
        return mState;
40
0
    }
41
    float GetConfidence(void) override;
42
43
    std::string StatusOutput(uint8_t indent) override;
44
45
protected:
46
    std::unique_ptr<nsCodingStateMachine> mCodingSM;
47
    nsProbingState mState = eDetecting;
48
49
    SJISContextAnalysis mContextAnalyser;
50
    SJISDistributionAnalysis mDistributionAnalyser;
51
52
    char mLastChar[2] = {0};
53
    int64_t mLastStart = -1;
54
};
55
}
56
57
#endif /* nsSJISProber_h__ */