diff options
author | Leonard Richardson <leonardr@segfault.org> | 2021-02-13 11:51:13 -0500 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2021-02-13 11:51:13 -0500 |
commit | 8f763297abc8bb598c3aca25eccaef6db7f7c987 (patch) | |
tree | b0ded4fe88e1c10883d13d0c2000bd9f9374f53e /bs4/builder/__init__.py | |
parent | 4d8d9af1c841d1eec0e9e838a467579831268b8b (diff) |
Added a second way to pass specify encodings to UnicodeDammit and
EncodingDetector, based on the order of precedence defined in the
HTML5 spec, starting at:
https://html.spec.whatwg.org/multipage/parsing.html#parsing-with-a-known-character-encoding
Encodings in 'known_definite_encodings' are tried first, then
byte-order-mark sniffing is run, then encodings in 'user_encodings'
are tried. The old argument, 'override_encodings', is now a
deprecated alias for 'known_definite_encodings'.
This changes the default behavior of the html.parser and lxml tree
builders, in a way that may slightly improve encoding
detection but will probably have no effect. [bug=1889014]
Diffstat (limited to 'bs4/builder/__init__.py')
-rw-r--r-- | bs4/builder/__init__.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/bs4/builder/__init__.py b/bs4/builder/__init__.py index 03da4c6..b6e2c37 100644 --- a/bs4/builder/__init__.py +++ b/bs4/builder/__init__.py @@ -234,7 +234,8 @@ class TreeBuilder(object): :param markup: Some markup -- probably a bytestring. :param user_specified_encoding: The user asked to try this encoding. :param document_declared_encoding: The markup itself claims to be - in this encoding. + in this encoding. NOTE: This argument is not used by the + calling code and can probably be removed. :param exclude_encodings: The user asked _not_ to try any of these encodings. |