(path)
| 72 | |
| 73 | |
| 74 | def try_encoded_read(path): |
| 75 | encodings = ['utf_8', 'cp1251', 'iso-8859-1', 'koi8_r', 'cp1252', 'cp1250', 'latin1', 'utf_32'] |
| 76 | |
| 77 | for encoding in encodings: |
| 78 | try: |
| 79 | with open(path, 'r', encoding=encoding) as f: |
| 80 | return f.read() |
| 81 | except UnicodeDecodeError: |
| 82 | pass |
| 83 | |
| 84 | return None |
| 85 | |
| 86 | |
| 87 | def write_file(filename, content, byte_content=False): |