If you pass the encoding to FileHandler , it uses codecs.open() with that encoding to open the file; otherwise, regular open() . To use all encoding .
Remember that Python 2.x is not ideal when handling bytes correctly and in Unicode: there is implicit encoding and decoding that occurs at different times, which can lift you up. You really shouldn't pass a string like "São" like bytes in most cases: if text, you should work with Unicode objects.
As for line endings, this usually translates into final lines for the platform, created by Python's I / O mechanisms for files. But if codecs.open() , the main file is opened in binary mode, so there is no translation of \n to \r\n , as is usually the case in Windows.
Vinay sajip
source share