IronLanguages / IronLanguages/ironpython3
bytes.decode("utf-16") not detecting BOM
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.8k
- Forks
- 316
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 1
Description
To reproduce:
assert b'\xfe\xff\x00A'.decode("utf-16") == "A"
As a workaround, codecs.decode seems to work properly:
import codecs
assert codecs.decode(b'\xfe\xff\x00A', "utf-16") == "A"
Ran into this while testing PyPDF2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of bytes.decode("utf-16") and compare its behavior with codecs.decode on the provided BOM-prefixed bytes. Reproduce the assertion, then verify that bytes.decode detects the BOM and returns "A" as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100