12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
32e5b6d6dSopenharmony_ci/*
42e5b6d6dSopenharmony_ci **********************************************************************
52e5b6d6dSopenharmony_ci *   Copyright (C) 2005-2016, International Business Machines
62e5b6d6dSopenharmony_ci *   Corporation and others.  All Rights Reserved.
72e5b6d6dSopenharmony_ci **********************************************************************
82e5b6d6dSopenharmony_ci */
92e5b6d6dSopenharmony_ci
102e5b6d6dSopenharmony_ci#ifndef __CSDETECT_H
112e5b6d6dSopenharmony_ci#define __CSDETECT_H
122e5b6d6dSopenharmony_ci
132e5b6d6dSopenharmony_ci#include "unicode/uobject.h"
142e5b6d6dSopenharmony_ci
152e5b6d6dSopenharmony_ci#if !UCONFIG_NO_CONVERSION
162e5b6d6dSopenharmony_ci
172e5b6d6dSopenharmony_ci#include "unicode/uenum.h"
182e5b6d6dSopenharmony_ci
192e5b6d6dSopenharmony_ciU_NAMESPACE_BEGIN
202e5b6d6dSopenharmony_ci
212e5b6d6dSopenharmony_ciclass InputText;
222e5b6d6dSopenharmony_ciclass CharsetRecognizer;
232e5b6d6dSopenharmony_ciclass CharsetMatch;
242e5b6d6dSopenharmony_ci
252e5b6d6dSopenharmony_ciclass CharsetDetector : public UMemory
262e5b6d6dSopenharmony_ci{
272e5b6d6dSopenharmony_ciprivate:
282e5b6d6dSopenharmony_ci    InputText *textIn;
292e5b6d6dSopenharmony_ci    CharsetMatch **resultArray;
302e5b6d6dSopenharmony_ci    int32_t resultCount;
312e5b6d6dSopenharmony_ci    UBool fStripTags;   // If true, setText() will strip tags from input text.
322e5b6d6dSopenharmony_ci    UBool fFreshTextSet;
332e5b6d6dSopenharmony_ci    static void setRecognizers(UErrorCode &status);
342e5b6d6dSopenharmony_ci
352e5b6d6dSopenharmony_ci    UBool *fEnabledRecognizers;  // If not null, active set of charset recognizers had
362e5b6d6dSopenharmony_ci                                // been changed from the default. The array index is
372e5b6d6dSopenharmony_ci                                // corresponding to fCSRecognizers. See setDetectableCharset().
382e5b6d6dSopenharmony_ci
392e5b6d6dSopenharmony_cipublic:
402e5b6d6dSopenharmony_ci    CharsetDetector(UErrorCode &status);
412e5b6d6dSopenharmony_ci
422e5b6d6dSopenharmony_ci    ~CharsetDetector();
432e5b6d6dSopenharmony_ci
442e5b6d6dSopenharmony_ci    void setText(const char *in, int32_t len);
452e5b6d6dSopenharmony_ci
462e5b6d6dSopenharmony_ci    const CharsetMatch * const *detectAll(int32_t &maxMatchesFound, UErrorCode &status);
472e5b6d6dSopenharmony_ci
482e5b6d6dSopenharmony_ci    const CharsetMatch *detect(UErrorCode& status);
492e5b6d6dSopenharmony_ci
502e5b6d6dSopenharmony_ci    void setDeclaredEncoding(const char *encoding, int32_t len) const;
512e5b6d6dSopenharmony_ci
522e5b6d6dSopenharmony_ci    UBool setStripTagsFlag(UBool flag);
532e5b6d6dSopenharmony_ci
542e5b6d6dSopenharmony_ci    UBool getStripTagsFlag() const;
552e5b6d6dSopenharmony_ci
562e5b6d6dSopenharmony_ci//    const char *getCharsetName(int32_t index, UErrorCode& status) const;
572e5b6d6dSopenharmony_ci
582e5b6d6dSopenharmony_ci    static int32_t getDetectableCount();
592e5b6d6dSopenharmony_ci
602e5b6d6dSopenharmony_ci
612e5b6d6dSopenharmony_ci    static UEnumeration * getAllDetectableCharsets(UErrorCode &status);
622e5b6d6dSopenharmony_ci    UEnumeration * getDetectableCharsets(UErrorCode &status) const;
632e5b6d6dSopenharmony_ci    void setDetectableCharset(const char *encoding, UBool enabled, UErrorCode &status);
642e5b6d6dSopenharmony_ci};
652e5b6d6dSopenharmony_ci
662e5b6d6dSopenharmony_ciU_NAMESPACE_END
672e5b6d6dSopenharmony_ci
682e5b6d6dSopenharmony_ci#endif
692e5b6d6dSopenharmony_ci#endif /* __CSDETECT_H */
70