If a document is opened with the encoding "Western (Windows 1252)" that contains invalid UTF-8 an error appears in the console:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 303, in on_activated
callback.on_activated(v)
File "/Users/dave/Library/Application Support/Sublime Text 3/Installed Packages/TrailingSpaces.sublime-package/trailing_spaces.py", line 395, in on_activated
self.freeze_last_version(view)
File "/Users/dave/Library/Application Support/Sublime Text 3/Installed Packages/TrailingSpaces.sublime-package/trailing_spaces.py", line 416, in freeze_last_version
on_disk = codecs.open(file_name, "r", "utf-8").read().splitlines()
File "X/codecs.py", line 679, in read
File "X/codecs.py", line 482, in read
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 1789: invalid start byte
Perhaps a conditional to get the encoding of the document could help, as with this example (line 36):
If a document is opened with the encoding "Western (Windows 1252)" that contains invalid UTF-8 an error appears in the console:
Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 303, in on_activated callback.on_activated(v) File "/Users/dave/Library/Application Support/Sublime Text 3/Installed Packages/TrailingSpaces.sublime-package/trailing_spaces.py", line 395, in on_activated self.freeze_last_version(view) File "/Users/dave/Library/Application Support/Sublime Text 3/Installed Packages/TrailingSpaces.sublime-package/trailing_spaces.py", line 416, in freeze_last_version on_disk = codecs.open(file_name, "r", "utf-8").read().splitlines() File "X/codecs.py", line 679, in read File "X/codecs.py", line 482, in read UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 1789: invalid start byte
Perhaps a conditional to get the encoding of the document could help, as with this example (line 36):
https://github.com/demon386/SmartMarkdown/blob/master/pandoc_render.py
It doesn't appear to be possible to get the codec name from Sublime Text (only the long name) to match up with this list:
http://docs.python.org/release/2.5.2/lib/standard-encodings.html