Yamale icon indicating copy to clipboard operation
Yamale copied to clipboard

Let users choose the file encoding

Open reconman opened this issue 3 years ago • 4 comments

Fixes #189

I've added some type hints and comments to the user-facing functions. Wasn't sure about the type of validator, so it's still Any.

reconman avatar Feb 06 '22 12:02 reconman

As an aside, I think this would be a breaking change--Windows-only users (or anyone with a supported non-utf-8 text encoding set as their locale) may be unwittingly, or intentionally, relying on this behavior.

mechie avatar Feb 06 '22 16:02 mechie

I agree @mechie , more comments in #189 .

mildebrandt avatar Feb 07 '22 05:02 mildebrandt

I've changed it to the system default. Tested it with the value Chūnibyō demo Koi ga Shitai! in a YAML file. If I encode it as CP1252, it can be parsed on Windows. If I use UTF-8 instead, an exception is thrown.

Not really happy with copy-pasting the locale function call everywhere but I'm not a professional Python programmer, so there may be better ways.

reconman avatar Feb 09 '22 22:02 reconman

Thanks for your PR. Let me think a bit about the best way to handle this. Maybe instead of passing the encoding through several layers of functions, we could introduce a config mechanism.

mildebrandt avatar Feb 10 '22 16:02 mildebrandt