__init__.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # -*- coding: utf-8 -*-
  2. """
  3. Charset-Normalizer
  4. ~~~~~~~~~~~~~~
  5. The Real First Universal Charset Detector.
  6. A library that helps you read text from an unknown charset encoding.
  7. Motivated by chardet, This package is trying to resolve the issue by taking a new approach.
  8. All IANA character set names for which the Python core library provides codecs are supported.
  9. Basic usage:
  10. >>> from charset_normalizer import from_bytes
  11. >>> results = from_bytes('Bсеки човек има право на образование. Oбразованието!'.encode('utf_8'))
  12. >>> best_guess = results.best()
  13. >>> str(best_guess)
  14. 'Bсеки човек има право на образование. Oбразованието!'
  15. Others methods and usages are available - see the full documentation
  16. at <https://github.com/Ousret/charset_normalizer>.
  17. :copyright: (c) 2021 by Ahmed TAHRI
  18. :license: MIT, see LICENSE for more details.
  19. """
  20. import logging
  21. from .api import from_bytes, from_fp, from_path, is_binary
  22. from .legacy import detect
  23. from .models import CharsetMatch, CharsetMatches
  24. from .utils import set_logging_handler
  25. from .version import VERSION, __version__
  26. __all__ = (
  27. "from_fp",
  28. "from_path",
  29. "from_bytes",
  30. "is_binary",
  31. "detect",
  32. "CharsetMatch",
  33. "CharsetMatches",
  34. "__version__",
  35. "VERSION",
  36. "set_logging_handler",
  37. )
  38. # Attach a NullHandler to the top level logger by default
  39. # https://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library
  40. logging.getLogger("charset_normalizer").addHandler(logging.NullHandler())