xref: /aosp_15_r20/external/icu/libicu/cts_headers/csdetect.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker  **********************************************************************
5*0e209d39SAndroid Build Coastguard Worker  *   Copyright (C) 2005-2016, International Business Machines
6*0e209d39SAndroid Build Coastguard Worker  *   Corporation and others.  All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker  **********************************************************************
8*0e209d39SAndroid Build Coastguard Worker  */
9*0e209d39SAndroid Build Coastguard Worker 
10*0e209d39SAndroid Build Coastguard Worker #ifndef __CSDETECT_H
11*0e209d39SAndroid Build Coastguard Worker #define __CSDETECT_H
12*0e209d39SAndroid Build Coastguard Worker 
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/uobject.h"
14*0e209d39SAndroid Build Coastguard Worker 
15*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_CONVERSION
16*0e209d39SAndroid Build Coastguard Worker 
17*0e209d39SAndroid Build Coastguard Worker #include "unicode/uenum.h"
18*0e209d39SAndroid Build Coastguard Worker 
19*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker class InputText;
22*0e209d39SAndroid Build Coastguard Worker class CharsetRecognizer;
23*0e209d39SAndroid Build Coastguard Worker class CharsetMatch;
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker class CharsetDetector : public UMemory
26*0e209d39SAndroid Build Coastguard Worker {
27*0e209d39SAndroid Build Coastguard Worker private:
28*0e209d39SAndroid Build Coastguard Worker     InputText *textIn;
29*0e209d39SAndroid Build Coastguard Worker     CharsetMatch **resultArray;
30*0e209d39SAndroid Build Coastguard Worker     int32_t resultCount;
31*0e209d39SAndroid Build Coastguard Worker     UBool fStripTags;   // If true, setText() will strip tags from input text.
32*0e209d39SAndroid Build Coastguard Worker     UBool fFreshTextSet;
33*0e209d39SAndroid Build Coastguard Worker     static void setRecognizers(UErrorCode &status);
34*0e209d39SAndroid Build Coastguard Worker 
35*0e209d39SAndroid Build Coastguard Worker     UBool *fEnabledRecognizers;  // If not null, active set of charset recognizers had
36*0e209d39SAndroid Build Coastguard Worker                                 // been changed from the default. The array index is
37*0e209d39SAndroid Build Coastguard Worker                                 // corresponding to fCSRecognizers. See setDetectableCharset().
38*0e209d39SAndroid Build Coastguard Worker 
39*0e209d39SAndroid Build Coastguard Worker public:
40*0e209d39SAndroid Build Coastguard Worker     CharsetDetector(UErrorCode &status);
41*0e209d39SAndroid Build Coastguard Worker 
42*0e209d39SAndroid Build Coastguard Worker     ~CharsetDetector();
43*0e209d39SAndroid Build Coastguard Worker 
44*0e209d39SAndroid Build Coastguard Worker     void setText(const char *in, int32_t len);
45*0e209d39SAndroid Build Coastguard Worker 
46*0e209d39SAndroid Build Coastguard Worker     const CharsetMatch * const *detectAll(int32_t &maxMatchesFound, UErrorCode &status);
47*0e209d39SAndroid Build Coastguard Worker 
48*0e209d39SAndroid Build Coastguard Worker     const CharsetMatch *detect(UErrorCode& status);
49*0e209d39SAndroid Build Coastguard Worker 
50*0e209d39SAndroid Build Coastguard Worker     void setDeclaredEncoding(const char *encoding, int32_t len) const;
51*0e209d39SAndroid Build Coastguard Worker 
52*0e209d39SAndroid Build Coastguard Worker     UBool setStripTagsFlag(UBool flag);
53*0e209d39SAndroid Build Coastguard Worker 
54*0e209d39SAndroid Build Coastguard Worker     UBool getStripTagsFlag() const;
55*0e209d39SAndroid Build Coastguard Worker 
56*0e209d39SAndroid Build Coastguard Worker //    const char *getCharsetName(int32_t index, UErrorCode& status) const;
57*0e209d39SAndroid Build Coastguard Worker 
58*0e209d39SAndroid Build Coastguard Worker     static int32_t getDetectableCount();
59*0e209d39SAndroid Build Coastguard Worker 
60*0e209d39SAndroid Build Coastguard Worker 
61*0e209d39SAndroid Build Coastguard Worker     static UEnumeration * getAllDetectableCharsets(UErrorCode &status);
62*0e209d39SAndroid Build Coastguard Worker     UEnumeration * getDetectableCharsets(UErrorCode &status) const;
63*0e209d39SAndroid Build Coastguard Worker     void setDetectableCharset(const char *encoding, UBool enabled, UErrorCode &status);
64*0e209d39SAndroid Build Coastguard Worker };
65*0e209d39SAndroid Build Coastguard Worker 
66*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
67*0e209d39SAndroid Build Coastguard Worker 
68*0e209d39SAndroid Build Coastguard Worker #endif
69*0e209d39SAndroid Build Coastguard Worker #endif /* __CSDETECT_H */
70