diff options
Diffstat (limited to 'beautifulsoup/builder/html5lib_builder.py')
-rw-r--r-- | beautifulsoup/builder/html5lib_builder.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/beautifulsoup/builder/html5lib_builder.py b/beautifulsoup/builder/html5lib_builder.py index dc95493..a5aaa01 100644 --- a/beautifulsoup/builder/html5lib_builder.py +++ b/beautifulsoup/builder/html5lib_builder.py @@ -18,6 +18,9 @@ class HTML5TreeBuilder(HTMLTreeBuilder): parser = html5lib.HTMLParser(tree=self.create_treebuilder) doc = parser.parse(markup) + # Set the character encoding detected by the tokenizer. + doc.originalEncoding = parser.tokenizer.stream.charEncoding[0] + def create_treebuilder(self, namespaceHTMLElements): self.underlying_builder = TreeBuilderForHtml5lib( self.soup, namespaceHTMLElements) |