10#include "kcodecs_export.h"
14#define NUM_OF_CATEGORY 6
16#define ENOUGH_REL_THRESHOLD 100
17#define MAX_REL_THRESHOLD 1000
18namespace kencodingprober
21extern const char jp2CharContext[83][83];
23class KCODECS_NO_EXPORT JapaneseContextAnalysis
26 JapaneseContextAnalysis()
30 virtual ~JapaneseContextAnalysis()
34 void HandleData(
const char *aBuf,
unsigned int aLen);
36 void HandleOneChar(
const char *aStr,
unsigned int aCharLen)
41 if (mTotalRel > MAX_REL_THRESHOLD) {
49 order = (aCharLen == 2) ? GetOrder(aStr) : -1;
50 if (order != -1 && mLastCharOrder != -1) {
53 mRelSample[(int)jp2CharContext[mLastCharOrder][order]]++;
55 mLastCharOrder = order;
58 float GetConfidence();
65 return mTotalRel > ENOUGH_REL_THRESHOLD;
69 virtual int GetOrder(
const char *str,
unsigned int *charLen) = 0;
70 virtual int GetOrder(
const char *str) = 0;
73 unsigned int mRelSample[NUM_OF_CATEGORY];
76 unsigned int mTotalRel;
83 unsigned int mNeedToSkipCharNum;
89class KCODECS_NO_EXPORT SJISContextAnalysis :
public JapaneseContextAnalysis
93 int GetOrder(
const char *str,
unsigned int *charLen)
override;
95 int GetOrder(
const char *str)
override
98 if (*str ==
'\202' && (
unsigned char)*(str + 1) >= (
unsigned char)0x9f && (
unsigned char)*(str + 1) <= (
unsigned char)0xf1) {
99 return (
unsigned char)*(str + 1) - (
unsigned char)0x9f;
105class KCODECS_NO_EXPORT EUCJPContextAnalysis :
public JapaneseContextAnalysis
108 int GetOrder(
const char *str,
unsigned int *charLen)
override;
109 int GetOrder(
const char *str)
override
113 && (
unsigned char)*(str + 1) >= (
unsigned char)0xa1
114 && (
unsigned char)*(str + 1) <= (
unsigned char)0xf3) {
115 return (
unsigned char)*(str + 1) - (
unsigned char)0xa1;
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.