atom/encoding-selector

Editor does not remember which encoding was selected for file

Opened this issue · 3 comments

  1. open file (encoding not recognized)
  2. select encoding, e.g. "windows 1251" (text displayed normally)
  3. you can do anything with the file: edit, save, or do nothing - it doesn't matter
  4. close tab with file
  5. open file again (encoding not recognized)

It makes almost impossible to work, if project contains files with different encodings

upd: edited title to be clearer

I believe you're asking for automatic detection of the encoding when you open the file. If so, this is being tracked under #24.

Not exactly. I was thinking about it for a long time. If we set "autodetection" as "default encoding", then which encoding, editor should use when saving or creating the file? Actually, the "default encoding" in project settings should only affect, which encoding will be used when creating or saving files. As for opening, it's natural, to open the file in the same encoding, which it originally has.
In this issue I was talking about manually selected encoding, not about autodetection. I've selected the encoding manually, and editor does not save this information somewhere. The next time running the editor I'll have to select encoding for this file again.
I think, that encoding autodetection, will not solve this issue completely. What if encoding autodetection would be "by default"? The opportunity of manual selection still remains? I think so. At least in cases, when autodetection fails. Anyway if someone has selected encoding manualy, then he has the reason for this. And in this case, editor should save this information somewhere in project metadata, to restore selected encoding later.
On the other hand, I agree that if encoding autodetection will work as it should, manual encoding selection maybe just will not be needed, except some rare case.

One workaround may be a text in the beginning of file in a comment section to indicate a fixed manual encoding, like shebang in unix shell files: https://en.wikipedia.org/wiki/Shebang_(Unix). In jEdit there is something similar for a per-file configuration. It may be useful by itself.
Another feature could be a default encoding per syntax mode (language). It may be useful too.