File: handling_result.rst

package info (click to toggle)
python-charset-normalizer 3.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: python: 5,434; makefile: 25; sh: 17
file content (25 lines) | stat: -rw-r--r-- 595 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
================
 Handling Result
================

When initiating search upon a buffer, bytes or file you can assign the return value and fully exploit it.

 ::

    my_byte_str = 'Bсеки човек има право на образование.'.encode('cp1251')

    # Assign return value so we can fully exploit result
    result = from_bytes(
        my_byte_str
    ).best()

    print(result.encoding)  # cp1251

Using CharsetMatch
----------------------------

Here, ``result`` is a ``CharsetMatch`` object or ``None``.

.. autoclass:: charset_normalizer.CharsetMatch
    :members: