Sublime Forum

Default encoding for new file and UTF-8 with BOM

#1

I asked this in the Build 2144 thread but my question is now deeply buried in the thread, so I try to make it a new topic:

API: Added view.encoding() and view.set_encoding() API: Added view.line_endings() and view.set_line_endings()
What’s the list of encodings accepted by set_encoding() ?
I try to get an UTF-8 with BOM but didn’t find how to spell it…

And is there any plan to have default encoding by syntax ?
Actually, I use different encoding for different language:
-Delphi and PL/SQL files -> cp1252
-Python -> utf-8 BOM
-Almost anything else -> utf-8

Actually new files are ‘Undefined’ and get an encoding when saved.
What I like is that the encoding used when the file is saved come from a settings in the Base File.sublime-settings (or the syntax specific one).
A warning message before saving if the encoding didn’t take care of some of the char in the buffer would be nice.

I’m pretty sure it’s easy to make a plugin that trap the on_pre_save event to do that work, but I just wonder if something is planned before doing it.

0 Likes

#2

The complete list of encodings is listed in Default/Main.sublime-menu, except for these ones:

"UTF-16 BE"
"UTF-16 BE with BOM"
"UTF-16 LE"
"UTF-16 LE with BOM"
"UTF-8"
"UTF-8 with BOM"

The BOM variants aren’t listed in the menu as they’re auto detected. I’m not currently planning on adding any functionality to support per-syntax encodings out of the box.

0 Likes

#3

I was sure that I tried “UTF-8 with BOM”, my mistake…
Thanks for your answer, I will take a look on how to make a plugin for this.

0 Likes