7#ifndef CharDistribution_h__
8#define CharDistribution_h__
10#include "kcodecs_export.h"
12#include <qcompilerdetection.h>
14#define ENOUGH_DATA_THRESHOLD 256
16namespace kencodingprober
18class KCODECS_NO_EXPORT CharDistributionAnalysis
21 CharDistributionAnalysis()
25 virtual ~CharDistributionAnalysis()
30 void HandleData(
const char * ,
unsigned int )
35 void HandleOneChar(
const char *aStr,
unsigned int aCharLen)
40 order = (aCharLen == 2) ? GetOrder(aStr) : -1;
45 if ((
unsigned int)order < mTableSize) {
46 if (512 > mCharToFreqOrder[order]) {
54 float GetConfidence();
74 return mTotalChars > ENOUGH_DATA_THRESHOLD;
81 virtual int GetOrder(
const char * )
90 unsigned int mFreqChars;
93 unsigned int mTotalChars;
96 const short *mCharToFreqOrder;
99 unsigned int mTableSize;
103 float mTypicalDistributionRatio;
106class KCODECS_NO_EXPORT EUCKRDistributionAnalysis :
public CharDistributionAnalysis
109 EUCKRDistributionAnalysis();
116 int GetOrder(
const char *str)
override
118 if ((
unsigned char)*str >= (
unsigned char)0xb0) {
119 return 94 * ((
unsigned char)str[0] - (
unsigned char)0xb0) + (
unsigned char)str[1] - (
unsigned char)0xa1;
126class KCODECS_NO_EXPORT GB2312DistributionAnalysis :
public CharDistributionAnalysis
129 GB2312DistributionAnalysis();
136 int GetOrder(
const char *str)
override
138 if ((
unsigned char)*str >= (
unsigned char)0xb0 && (
unsigned char)str[1] >= (
unsigned char)0xa1) {
139 return 94 * ((
unsigned char)str[0] - (
unsigned char)0xb0) + (
unsigned char)str[1] - (
unsigned char)0xa1;
146class KCODECS_NO_EXPORT Big5DistributionAnalysis :
public CharDistributionAnalysis
149 Big5DistributionAnalysis();
156 int GetOrder(
const char *str)
override
158 if ((
unsigned char)*str >= (
unsigned char)0xa4)
159 if ((
unsigned char)str[1] >= (
unsigned char)0xa1) {
160 return 157 * ((
unsigned char)str[0] - (
unsigned char)0xa4) + (
unsigned char)str[1] - (
unsigned char)0xa1 + 63;
162 return 157 * ((
unsigned char)str[0] - (
unsigned char)0xa4) + (
unsigned char)str[1] - (
unsigned char)0x40;
170class KCODECS_NO_EXPORT SJISDistributionAnalysis :
public CharDistributionAnalysis
173 SJISDistributionAnalysis();
180 int GetOrder(
const char *str)
override
183 if ((
unsigned char)*str >= (
unsigned char)0x81 && (
unsigned char)*str <= (
unsigned char)0x9f) {
184 order = 188 * ((
unsigned char)str[0] - (
unsigned char)0x81);
185 }
else if ((
unsigned char)*str >= (
unsigned char)0xe0 && (
unsigned char)*str <= (
unsigned char)0xef) {
186 order = 188 * ((
unsigned char)str[0] - (
unsigned char)0xe0 + 31);
190 order += (
unsigned char)*(str + 1) - 0x40;
191 if ((
unsigned char)str[1] > (
unsigned char)0x7f) {
198class KCODECS_NO_EXPORT EUCJPDistributionAnalysis :
public CharDistributionAnalysis
201 EUCJPDistributionAnalysis();
208 int GetOrder(
const char *str)
override
210 if ((
unsigned char)*str >= (
unsigned char)0xa0) {
211 return 94 * ((
unsigned char)str[0] - (
unsigned char)0xa1) + (
unsigned char)str[1] - (
unsigned char)0xa1;
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:08:36 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.