Giter Site home page Giter Site logo

Comments (11)

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

@atbest notice your result. The confidence value is 0.99, not 1.0 That means that this is not matching the way you expect it to, so this conditional is not evaluating to true. That means that chardet then starts using the probers to determine the character encoding. You'll likely have to determine how best to make a UTF8SIGProber in the likeness of UTF8Prober and a similar State Machine Model. Even then, given how similar the two encodings are (utf-8, utf-8-sig) you should understand that chardet works with probabilities and returns the encoding that statistically seems most likely so getting a consistently correct answer could be extraordinarily difficult.

I do appreciate that you're trying to fix this though.

from chardet.

atbest avatar atbest commented on June 12, 2024

Thanks for the information. And I found it's very easy to fix. Just change the codecs.BOM to codecs.BOM_UTF8.

            if aBuf[:3] == codecs.BOM_UTF8:
                # EF BB BF  UTF-8 with BOM
                self.result = {'encoding': "UTF-8-SIG", 'confidence': 1.0}

from chardet.

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

Could you please make a PR for this?

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

@atbest please be sure to add this instead of modifying the existing lines.

from chardet.

atbest avatar atbest commented on June 12, 2024

@dan-blanchard Sorry, what does PR stand for? I am new here...
@sigmavirus24 According to this page, codecs.BOM is FF FE, while aBuf[:3] is three bytes, and aBuf[:3] == codecs.BOM is always False, so it is not necessary to keep existing lines.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

@atbest you're right. Looking at the official documentation codecs.BOM is an alias for codecs.BOM_UTF16.

A PR is a Pull Request. You fork this repository, push your changes to your copy (preferably on a separate branch) and then click the button to create a pull request to this repository.

from chardet.

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

@atbest you can also just click the "edit" button on the GitHub page for the specific file you want to edit. That'll create the fork for you and make a PR when you hit save. It can be handy when you only have to make a one file change.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

@dan-blanchard it can be handy but I've also seen it destroy formatting because the ACE editor is terrible.

from chardet.

atbest avatar atbest commented on June 12, 2024

Allright, done. Thanks.

from chardet.

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024

Thanks @atbest

from chardet.

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

Fixed via #32.

Thanks @atbest!

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.