by a-french-anon · 2y ago · 0 comments
For UTF-16/32, knowing the endianness doesn't seem to be a frivolous functionality. And in fact, having to use heuristics-based detection via uchardet is a big mess, some kind of header should have been standardized since the start.
https://docs.python.org/3/library/codecs.html
The codec you're imagining would also make reading a file and writing it back change the file if it contains a BOM.