Re: Is it possible to set a default encoding when opening file?
It should be possible to set the default encoding for all files. I always work with UTF-8, but I have to disable the UTF-8 BOM because it causes problems when writing JSP. So, the file is not automatically detected as UTF-8 and some characters are rendered incorrectly. Being able to specify the character encoding based on the file type will not always work. How would it be possible if I were writing XML, XHTML of HTML, because they all have an .xml, .xhtml or .html extension respectively, but they can be in any encoding. For XML files it should be able to detect the character encoding from the xml prolog, or default to UTF-8 or UTF-16 as specifed in the spec, depending on the presence of, and which BOM is used. Refer to the XML spec for exact details of determining character encodings of XML files. For HTML files, it should detect it from the BOM, if included, or the meta element, if included or default to iso-8859-1 (IIRC) or, if set, the user's configured default which I would set to UTF-8. See the HTML spec for exact details. Another option would be to use the default until a UTF-8 character outside the ASCII or iso8859-1 range is detected. Notepad does this somehow, and always correctly detects the files as UTF-8 if they contain a chacter greater then U+007F. It probably detects the control characters (U+0080 to U+009F) or something like that.
|