Giter Site home page Giter Site logo

Comments (4)

dan-blanchard avatar dan-blanchard commented on June 12, 2024

Unfortunately, it's an artifact of having to rely on statistical models to detect encodings. Sometimes we're wrong because there's not enough evidence. One character with an umlaut doesn't give us much to go on. If you know you're going to be processing things like Python source files that might have a header that actually tells you the encoding, that's the better thing to rely on.

from chardet.

 avatar commented on June 12, 2024

Thanks for the reply. OK, i understand. I just have been wondering why file gets it correctly.

from chardet.

dan-blanchard avatar dan-blanchard commented on June 12, 2024

file probably just has models that are biased toward UTF-8. It's also possible it checks for headers. I'm not sure the exact algorithm uses, but it can detect far fewer encodings than we can.

from chardet.

Tronic avatar Tronic commented on June 12, 2024

Valid UTF-8 sequences (w or w/o BOM) as well as any Unicode sequence with BOM should always take precedence over 8-bit encodings. Unfortunately I'm getting more failures than correct detections from chardet, and often an encoding that cannot even be decoded is reported. I was forced to write my own function that, despite being simple, performs much better. https://paste.zi.fi/p/decode.py/view

from chardet.

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.