12#include "nsSJISProber.h"
14namespace kencodingprober
16void nsSJISProber::Reset(
void)
20 mContextAnalyser.Reset();
21 mDistributionAnalyser.Reset();
24nsProbingState nsSJISProber::HandleData(
const char *aBuf,
unsigned int aLen)
30 for (
unsigned int i = 0; i < aLen; i++) {
31 const nsSMState codingState = mCodingSM->NextState(aBuf[i]);
32 if (codingState == eError) {
36 if (codingState == eItsMe) {
40 if (codingState == eStart) {
41 unsigned int charLen = mCodingSM->GetCurrentCharLen();
43 mLastChar[1] = aBuf[0];
44 mContextAnalyser.HandleOneChar(mLastChar + 2 - charLen, charLen);
45 mDistributionAnalyser.HandleOneChar(mLastChar, charLen);
47 mContextAnalyser.HandleOneChar(aBuf + i + 1 - charLen, charLen);
48 mDistributionAnalyser.HandleOneChar(aBuf + i - 1, charLen);
53 mLastChar[0] = aBuf[aLen - 1];
55 if (mState == eDetecting) {
56 if (mContextAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) {
64float nsSJISProber::GetConfidence(
void)
66 float contxtCf = mContextAnalyser.GetConfidence();
67 float distribCf = mDistributionAnalyser.GetConfidence();
69 return (contxtCf > distribCf ? contxtCf : distribCf);
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:52 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.