Skip to content

Incorrect handling of UTF-8 encoding during preprocessing #44

Open

Description

@refack

Example:

cppreference-doc-20250209\reference\en.cppreference.com\w\cpp\header\bit.html:4 which is the page title

  • the raw dump has it correctly:
    <title>Standard library header &lt;bit> (C++20) - cppreference.com</title>
    it's just UTF-8 encoded
    Image
  • the html in the zip (also in the .tar.xz) has it twice encoded:
    html-book-20250209.zip\reference\en\cpp\header\bit.html
    <title>Standard library header &lt;bit&gt; (C++20) - cppreference.com</title>
    adding \u00C2 kruft
    Image

I'd be happy to look into it.

Activity

  1. changed the title [-]script mangles &nbps; (a.k.a. \u00A0) and I assume any char > `\0x7F` that's beyond the ASCII table[/-] [+]script mangles &nbps; (a.k.a. \u00A0) and I assume any char > \0x7F that's beyond the ASCII table[/+] on Apr 20, 2025
  2. changed the title [-]script mangles &nbps; (a.k.a. \u00A0) and I assume any char > \0x7F that's beyond the ASCII table[/-] [+]Incorrect handling of UTF-8 encoding during preprocessing[/+] on Apr 25, 2025
  3. PeterFeicht commented on Apr 25, 2025

    @PeterFeicht
    Owner

    Yep, looks like a bug. I'm assuming we need to explicitly set the source encoding somewhere during preprocessing.

  4. refack commented on Apr 25, 2025

    @refack
    Author

    parser = etree.HTMLParser()

    HTMLParser(encoding='utf-8')

    I'll post a PR shortly.
    I got sucked into a slightly bigger change using BeautifulSoup which makes things simpler and more robust. Strangely MediaWiki renders wonky HTML mixing up end tags order e.g. <div><ul><li></li></div></ul>. But that should be a different PR and a whole new conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions