Giter Site home page Giter Site logo

Comments (3)

glebourgeois avatar glebourgeois commented on July 19, 2024

I did not look yet into these two examples specifically, but considering this :

if self.doc.source_headers.get("content-type"):
            header_encoding = get_encoding_from_content_type(self.doc.source_headers["content-type"])
            if header_encoding:
                return header_encoding

I can assure you that you cannot trust the encoding specified in headers ; they are quite often badly declared.

from cosr-back.

sylvinus avatar sylvinus commented on July 19, 2024

Indeed!

Do you have another solution in mind? Would be great to avoid doing chardet on all documents just to fix the <1% cases where they are badly declared :(

from cosr-back.

glebourgeois avatar glebourgeois commented on July 19, 2024

Nope, you just cannot trust your input data, that's the beauty of the web ;)
And as you know, garbage in, garbage out.

By the way, on the "true web", id most of the websites hand-written by noob dev, you'll have far more than 1% errors ; they will have copy/pasted an example with utf-8 declaration from the web, while writing html code in windows notepad with windows-1252 encoding.
And as the browsers are systematically detecting the encodings before displaying a page, the will never know their mistakes.... (thanks for the legendary browsers tolerance)

from cosr-back.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.