Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/charset_normalizer/__init__.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

10 statements  

1""" 

2Charset-Normalizer 

3~~~~~~~~~~~~~~ 

4The Real First Universal Charset Detector. 

5A library that helps you read text from an unknown charset encoding. 

6Motivated by chardet, This package is trying to resolve the issue by taking a new approach. 

7All IANA character set names for which the Python core library provides codecs are supported. 

8 

9Basic 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 

16Others methods and usages are available - see the full documentation 

17at <https://github.com/Ousret/charset_normalizer>. 

18:copyright: (c) 2021 by Ahmed TAHRI 

19:license: MIT, see LICENSE for more details. 

20""" 

21 

22from __future__ import annotations 

23 

24import logging 

25 

26from .api import from_bytes, from_fp, from_path, is_binary 

27from .legacy import detect 

28from .models import CharsetMatch, CharsetMatches 

29from .utils import set_logging_handler 

30from .version import VERSION, __version__ 

31 

32__all__ = ( 

33 "from_fp", 

34 "from_path", 

35 "from_bytes", 

36 "is_binary", 

37 "detect", 

38 "CharsetMatch", 

39 "CharsetMatches", 

40 "__version__", 

41 "VERSION", 

42 "set_logging_handler", 

43) 

44 

45# Attach a NullHandler to the top level logger by default 

46# https://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library 

47 

48logging.getLogger("charset_normalizer").addHandler(logging.NullHandler())