2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2006-02-06 18:03:11 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (C) 2005-2016, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2006-02-06 18:03:11 +00:00
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CSDETECT_H
|
|
|
|
#define __CSDETECT_H
|
|
|
|
|
|
|
|
#include "unicode/uobject.h"
|
|
|
|
|
2006-05-09 18:06:10 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
2016-02-24 00:49:51 +00:00
|
|
|
#include "unicode/uenum.h"
|
|
|
|
|
2006-02-06 18:03:11 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class InputText;
|
|
|
|
class CharsetRecognizer;
|
2006-02-06 20:45:30 +00:00
|
|
|
class CharsetMatch;
|
2006-02-06 18:03:11 +00:00
|
|
|
|
2006-02-06 20:45:30 +00:00
|
|
|
class CharsetDetector : public UMemory
|
2006-02-06 18:03:11 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
InputText *textIn;
|
2006-02-06 20:45:30 +00:00
|
|
|
CharsetMatch **resultArray;
|
2006-02-07 20:24:16 +00:00
|
|
|
int32_t resultCount;
|
2006-02-06 18:03:11 +00:00
|
|
|
UBool fStripTags; // If true, setText() will strip tags from input text.
|
|
|
|
UBool fFreshTextSet;
|
2006-08-21 23:35:23 +00:00
|
|
|
static void setRecognizers(UErrorCode &status);
|
2006-02-06 18:03:11 +00:00
|
|
|
|
2013-09-17 06:57:53 +00:00
|
|
|
UBool *fEnabledRecognizers; // If not null, active set of charset recognizers had
|
|
|
|
// been changed from the default. The array index is
|
|
|
|
// corresponding to fCSRecognizers. See setDetectableCharset().
|
|
|
|
|
2006-02-06 18:03:11 +00:00
|
|
|
public:
|
2006-08-21 23:35:23 +00:00
|
|
|
CharsetDetector(UErrorCode &status);
|
2006-02-06 18:03:11 +00:00
|
|
|
|
2006-02-06 20:45:30 +00:00
|
|
|
~CharsetDetector();
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
void setText(const char *in, int32_t len);
|
|
|
|
|
2006-02-06 20:45:30 +00:00
|
|
|
const CharsetMatch * const *detectAll(int32_t &maxMatchesFound, UErrorCode &status);
|
2006-02-06 18:03:11 +00:00
|
|
|
|
2006-02-06 20:45:30 +00:00
|
|
|
const CharsetMatch *detect(UErrorCode& status);
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
void setDeclaredEncoding(const char *encoding, int32_t len) const;
|
|
|
|
|
|
|
|
UBool setStripTagsFlag(UBool flag);
|
|
|
|
|
|
|
|
UBool getStripTagsFlag() const;
|
|
|
|
|
2006-11-16 20:32:23 +00:00
|
|
|
// const char *getCharsetName(int32_t index, UErrorCode& status) const;
|
2006-02-06 18:03:11 +00:00
|
|
|
|
2013-09-17 06:57:53 +00:00
|
|
|
static int32_t getDetectableCount();
|
|
|
|
|
|
|
|
|
|
|
|
static UEnumeration * getAllDetectableCharsets(UErrorCode &status);
|
|
|
|
UEnumeration * getDetectableCharsets(UErrorCode &status) const;
|
|
|
|
void setDetectableCharset(const char *encoding, UBool enabled, UErrorCode &status);
|
2006-02-06 18:03:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2006-05-09 18:06:10 +00:00
|
|
|
#endif
|
2006-02-06 18:03:11 +00:00
|
|
|
#endif /* __CSDETECT_H */
|