Skip to content

Incorrectly detecting valid UTF-16 as UTF-32LE, for which it is invalid #62

@DRMacIver

Description

@DRMacIver

Given the following string:

u'\x000'.encode('utf-16')

chardet.detect as of 2.3.0 reports this as 'UTF-32LE' with a confidence of 1.0, but attempting to decode it as such fails with

UnicodeDecodeError: 'utf32' codec can't decode bytes in position 4-5: truncated data

I found this bug using Hypothesis. I'd be happy to submit a pull request adding the test that found it if you'd like me to, though it is of course currently failing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions