Home Download Buy Blog Forum Support

Default encoding for new file and UTF-8 with BOM

Default encoding for new file and UTF-8 with BOM

Postby bizoo on Thu Dec 01, 2011 7:18 am

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:

Code: Select all
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.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Default encoding for new file and UTF-8 with BOM

Postby jps on Thu Dec 01, 2011 1:29 pm

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

Code: Select all
"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.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Default encoding for new file and UTF-8 with BOM

Postby bizoo on Thu Dec 01, 2011 2:26 pm

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.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 35 guests