1/* -*- C++ -*-
2 SPDX-FileCopyrightText: 1998 Netscape Communications Corporation <developer@mozilla.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef nsCharSetProber_h__
8#define nsCharSetProber_h__
9
10#include <kcodecs_export.h>
11
12#include "../kencodingprober_p.h"
13
14namespace kencodingprober
15{
16typedef enum {
17 eDetecting = 0, // We are still detecting, no sure answer yet, but caller can ask for confidence.
18 eFoundIt = 1, // That's a positive answer
19 eNotMe = 2, // Negative answer
20} nsProbingState;
21
22#define SHORTCUT_THRESHOLD (float)0.95
23
24class KCODECS_NO_EXPORT nsCharSetProber
25{
26public:
27 virtual ~nsCharSetProber()
28 {
29 }
30 virtual const char *GetCharSetName() = 0;
31 virtual nsProbingState HandleData(const char *aBuf, unsigned int aLen) = 0;
32 virtual nsProbingState GetState(void) = 0;
33 virtual void Reset(void) = 0;
34 virtual float GetConfidence(void) = 0;
35
36#ifdef DEBUG_PROBE
37 virtual void DumpStatus()
38 {
39 }
40#endif
41
42 // Helper functions used in the Latin1 and Group probers.
43 // both functions Allocate a new buffer for newBuf. This buffer should be
44 // freed by the caller using PR_FREEIF.
45 // Both functions return false in case of memory allocation failure.
46 static bool FilterWithoutEnglishLetters(const char *aBuf, unsigned int aLen, char **newBuf, unsigned int &newLen);
47 static bool FilterWithEnglishLetters(const char *aBuf, unsigned int aLen, char **newBuf, unsigned int &newLen);
48};
49}
50#endif /* nsCharSetProber_h__ */
51

source code of kcodecs/src/probers/nsCharSetProber.h