Textualize / rich-cli

Rich-cli is a command line toolbox for fancy output in the terminal
https://www.textualize.io
MIT License
3.04k stars 75 forks source link

please detect encoding before opening a file #88

Open HaujetZhao opened 1 year ago

HaujetZhao commented 1 year ago

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.