ich habe ein super-einfaches Script:
Code: Alles auswählen
#!/usr/bin/env python3
import ftfy
import sys
ftfy_result = ftfy.fix_file(open(sys.argv[1]), 'utf-8')
fixed_string = ""
for line in ftfy_result:
fixed_string = fixed_string + line
print(fixed_string)
Trixis-Mac-Pro:~ beatrixwillius$ /Users/beatrixwillius/dist/fix_encoding.app/Contents/MacOS/fix_encoding /Users/beatrixwillius/Desktop/test.txt
Traceback (most recent call last):
File "/Users/beatrixwillius/dist/fix_encoding.app/Contents/Resources/__boot__.py", line 98, in <module>
_run()
File "/Users/beatrixwillius/dist/fix_encoding.app/Contents/Resources/__boot__.py", line 82, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Users/beatrixwillius/dist/fix_encoding.app/Contents/Resources/fix_encoding.py", line 8, in <module>
for line in ftfy_result:
File "ftfy/__init__.pyc", line 219, in fix_file
File "encodings/ascii.pyc", line 26, in decode
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
2018-03-17 14:58:44.907 fix_encoding[11128:3843692] fix_encoding Error
Da ich das ja nicht im Debugger bekomme, habe ich keine Ahnung, wie ich das beheben soll. Das übliche "encode('utf8')" bei der line-Variable hat nicht geholfen.
Ich habe das Programm und meine Test-Datei auf http://www.mothsoftware.com/downloads/fix.zip hochgeladen .
macOS 10.11, Python 3.6.
Grüße
Beatrix Willius