Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Use charset-normalizer for better coding detection#99

Merged
xingyaoww merged 1 commit into
mainfrom
better-coding-detection
Mar 22, 2025
Merged

Use charset-normalizer for better coding detection#99
xingyaoww merged 1 commit into
mainfrom
better-coding-detection

Conversation

@ryanhoangt

@ryanhoangt ryanhoangt commented Mar 22, 2025

Copy link
Copy Markdown
Member

Description

Previously we used chardet for coding detection, and when running on README files with emojis, for some reasons it detected the encoding to be Windows-1252 with confidence higher than our threshold (0.73). This PR replaces it with a more modern encoding detection library to avoid that issue.

Related Issue

Close #97

@ryanhoangt ryanhoangt requested a review from xingyaoww March 22, 2025 15:53
"""Test detecting UTF-8 encoding with a word and an emoji."""
# Create a UTF-8 encoded file with a single word and an emoji
with open(temp_file, 'w', encoding='utf-8') as f:
f.write('Hello 😊')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍😅

@xingyaoww xingyaoww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 welp - this is unexpected. Thanks for fixing it!

@xingyaoww xingyaoww merged commit 0a45ff1 into main Mar 22, 2025
@ryanhoangt ryanhoangt deleted the better-coding-detection branch March 23, 2025 08:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Catch UnicodeDecodeError in the openhands-aci package

3 participants