csrecog.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (C) 2005-2012, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. */
  9. #ifndef __CSRECOG_H
  10. #define __CSRECOG_H
  11. #include "unicode/uobject.h"
  12. #if !UCONFIG_NO_CONVERSION
  13. #include "inputext.h"
  14. U_NAMESPACE_BEGIN
  15. class CharsetMatch;
  16. class CharsetRecognizer : public UMemory
  17. {
  18. public:
  19. /**
  20. * Get the IANA name of this charset.
  21. * Note that some recognizers can recognize more than one charset, but that this API
  22. * assumes just one name per recognizer.
  23. * TODO: need to account for multiple names in public API that enumerates over the
  24. * known detectable charsets.
  25. * @return the charset name.
  26. */
  27. virtual const char *getName() const = 0;
  28. /**
  29. * Get the ISO language code for this charset.
  30. * @return the language code, or <code>null</code> if the language cannot be determined.
  31. */
  32. virtual const char *getLanguage() const;
  33. /*
  34. * Try the given input text against this Charset, and fill in the results object
  35. * with the quality of the match plus other information related to the match.
  36. *
  37. * Return TRUE if the the input bytes are a potential match, and
  38. * FALSE if the input data is not compatible with, or illegal in this charset.
  39. */
  40. virtual UBool match(InputText *textIn, CharsetMatch *results) const = 0;
  41. virtual ~CharsetRecognizer();
  42. };
  43. U_NAMESPACE_END
  44. #endif
  45. #endif /* __CSRECOG_H */