Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please detect encoding before opening a file #88

Open
HaujetZhao opened this issue Jun 3, 2023 · 0 comments
Open

please detect encoding before opening a file #88

HaujetZhao opened this issue Jun 3, 2023 · 0 comments

Comments

@HaujetZhao
Copy link

Please introduce modules to detect file encoding.

chardet is an option.

The default behavior of rich-cli opening a file is using system prefered encoding. Windows in some different country have different locale encoding.

So rich-cli will raise error if attempt to open utf-8 files.

The solution is: open file in bytes mode, read the bytes, detect the encoding using chardet module, decode the bytes to text content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant