Giter Site home page Giter Site logo

Comments (4)

sigmavirus24 avatar sigmavirus24 commented on June 12, 2024 1

If the string we're given isn't a byte string, then we have to encode it. However we choose to encode it will bias the detector. We need a raw byte string to give you accurate results. Can you explain what you were doing in requests such that chardet.detect received anything other than a bytestring?

from chardet.

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

@animenon Is this just standard Python 3.4? If so, then you probably passed a str object (what unicode became in Python 3) instead of a bytes object to chardet. Make sure that any files you're reading are being opened with mode set to 'rb' so that you'll get bytes instead of str.

from chardet.

animenon avatar animenon commented on June 12, 2024

I get this while invoking chardet from a python3.4 :

Traceback (most recent call last):
File "C:\xyz\detectChar.py", line 3, in
result = chardet.detect(rawdata)
File "C:\Python34\lib\site-packages\chardet__init__.py", line 25, in detect
raise ValueError('Expected a bytes object, not a unicode object')
ValueError: Expected a bytes object, not a unicode object

from chardet.

animenon avatar animenon commented on June 12, 2024

@dan-blanchard Thank you.

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.