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-2012, 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 __CSRECOG_H 11*0e209d39SAndroid Build Coastguard Worker #define __CSRECOG_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 "inputext.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 CharsetMatch; 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker class CharsetRecognizer : public UMemory 24*0e209d39SAndroid Build Coastguard Worker { 25*0e209d39SAndroid Build Coastguard Worker public: 26*0e209d39SAndroid Build Coastguard Worker /** 27*0e209d39SAndroid Build Coastguard Worker * Get the IANA name of this charset. 28*0e209d39SAndroid Build Coastguard Worker * Note that some recognizers can recognize more than one charset, but that this API 29*0e209d39SAndroid Build Coastguard Worker * assumes just one name per recognizer. 30*0e209d39SAndroid Build Coastguard Worker * TODO: need to account for multiple names in public API that enumerates over the 31*0e209d39SAndroid Build Coastguard Worker * known detectable charsets. 32*0e209d39SAndroid Build Coastguard Worker * @return the charset name. 33*0e209d39SAndroid Build Coastguard Worker */ 34*0e209d39SAndroid Build Coastguard Worker virtual const char *getName() const = 0; 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker /** 37*0e209d39SAndroid Build Coastguard Worker * Get the ISO language code for this charset. 38*0e209d39SAndroid Build Coastguard Worker * @return the language code, or <code>null</code> if the language cannot be determined. 39*0e209d39SAndroid Build Coastguard Worker */ 40*0e209d39SAndroid Build Coastguard Worker virtual const char *getLanguage() const; 41*0e209d39SAndroid Build Coastguard Worker 42*0e209d39SAndroid Build Coastguard Worker /* 43*0e209d39SAndroid Build Coastguard Worker * Try the given input text against this Charset, and fill in the results object 44*0e209d39SAndroid Build Coastguard Worker * with the quality of the match plus other information related to the match. 45*0e209d39SAndroid Build Coastguard Worker * 46*0e209d39SAndroid Build Coastguard Worker * Return true if the the input bytes are a potential match, and 47*0e209d39SAndroid Build Coastguard Worker * false if the input data is not compatible with, or illegal in this charset. 48*0e209d39SAndroid Build Coastguard Worker */ 49*0e209d39SAndroid Build Coastguard Worker virtual UBool match(InputText *textIn, CharsetMatch *results) const = 0; 50*0e209d39SAndroid Build Coastguard Worker 51*0e209d39SAndroid Build Coastguard Worker virtual ~CharsetRecognizer(); 52*0e209d39SAndroid Build Coastguard Worker }; 53*0e209d39SAndroid Build Coastguard Worker 54*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 55*0e209d39SAndroid Build Coastguard Worker 56*0e209d39SAndroid Build Coastguard Worker #endif 57*0e209d39SAndroid Build Coastguard Worker #endif /* __CSRECOG_H */ 58