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-2015, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2006-02-06 18:03:11 +00:00
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CSR2022_H
|
|
|
|
#define __CSR2022_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2006-05-09 18:06:10 +00:00
|
|
|
#if !UCONFIG_NO_CONVERSION
|
|
|
|
|
2006-02-06 18:03:11 +00:00
|
|
|
#include "csrecog.h"
|
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2012-06-01 20:40:48 +00:00
|
|
|
class CharsetMatch;
|
|
|
|
|
2006-02-06 18:03:11 +00:00
|
|
|
/**
|
|
|
|
* class CharsetRecog_2022 part of the ICU charset detection imlementation.
|
|
|
|
* This is a superclass for the individual detectors for
|
|
|
|
* each of the detectable members of the ISO 2022 family
|
|
|
|
* of encodings.
|
|
|
|
*
|
|
|
|
* The separate classes are nested within this class.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
class CharsetRecog_2022 : public CharsetRecognizer
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~CharsetRecog_2022() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Matching function shared among the 2022 detectors JP, CN and KR
|
|
|
|
* Counts up the number of legal an unrecognized escape sequences in
|
|
|
|
* the sample of text, and computes a score based on the total number &
|
|
|
|
* the proportion that fit the encoding.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param text the byte buffer containing text to analyse
|
|
|
|
* @param textLen the size of the text in the byte.
|
|
|
|
* @param escapeSequences the byte escape sequences to test for.
|
|
|
|
* @return match quality, in the range of 0-100.
|
|
|
|
*/
|
2012-06-01 20:40:48 +00:00
|
|
|
int32_t match_2022(const uint8_t *text,
|
|
|
|
int32_t textLen,
|
|
|
|
const uint8_t escapeSequences[][5],
|
|
|
|
int32_t escapeSequences_length) const;
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class CharsetRecog_2022JP :public CharsetRecog_2022
|
|
|
|
{
|
2011-07-26 05:32:25 +00:00
|
|
|
public:
|
|
|
|
virtual ~CharsetRecog_2022JP();
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
const char *getName() const;
|
|
|
|
|
2012-06-01 20:40:48 +00:00
|
|
|
UBool match(InputText *textIn, CharsetMatch *results) const;
|
2006-02-06 18:03:11 +00:00
|
|
|
};
|
|
|
|
|
2015-02-20 19:31:33 +00:00
|
|
|
#if !UCONFIG_ONLY_HTML_CONVERSION
|
2006-02-06 18:03:11 +00:00
|
|
|
class CharsetRecog_2022KR :public CharsetRecog_2022 {
|
2011-07-26 05:32:25 +00:00
|
|
|
public:
|
|
|
|
virtual ~CharsetRecog_2022KR();
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
const char *getName() const;
|
|
|
|
|
2012-06-01 20:40:48 +00:00
|
|
|
UBool match(InputText *textIn, CharsetMatch *results) const;
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class CharsetRecog_2022CN :public CharsetRecog_2022
|
|
|
|
{
|
2011-07-26 05:32:25 +00:00
|
|
|
public:
|
|
|
|
virtual ~CharsetRecog_2022CN();
|
2006-02-06 18:03:11 +00:00
|
|
|
|
|
|
|
const char* getName() const;
|
|
|
|
|
2012-06-01 20:40:48 +00:00
|
|
|
UBool match(InputText *textIn, CharsetMatch *results) const;
|
2006-02-06 18:03:11 +00:00
|
|
|
};
|
2015-02-20 19:31:33 +00:00
|
|
|
#endif
|
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 /* __CSR2022_H */
|