ukinti/garnet

Explicitly set UTF8 when dealing with files

Closed this issue · 0 comments

>>> help(pathlib.Path.open)
Help on function open in module pathlib:

open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None)
    Open the file pointed by this path and return a file object, as
    the built-in open() function does.

>>> help(open)
...

    In text mode, if encoding is not specified the encoding used is platform
    dependent: locale.getpreferredencoding(False) is called to get the
    current locale encoding.

This means saving data in one system and loading it in another can trip you. It should probably use UTF8 anywhere to avoid this pitfall in the future.