I have SQL scripts created with MS SQL Server Management Studio which display illegible when viewed with NetBeans (will
attach screenshot). It looks like an encoding issue. The same file when given a .SQL extension instead of .sql (I am
using Linux so file extensions are case sensitive) displays fine in NetBeans. So my suspicion is that the component
dealing with text/x-sql files is determining the file encoding incorrectly.
Created attachment 75677 [details]
Screenshot of garbled display
May be I was a bit quick with this issue as it is not related to the file extension. Further investigation showed that
the problem is related to MS SQL Server Management Studio using UTF-16 encoding by default (can't seem to change the
default) when saving files and NetBeans appears not to be able to understand that encoding. Looking at the file in a
binary editor it appears to correctly start with the Unicode BOM so the format should be detectable.
Passing to editor - please evaluate. Thanks.
In general file encoding in Netbeans is set for a project and you can change it in Properties -> Sources -> Encoding.
The encoding will apply for all files in the project. However, some files can specify their own encoding independently
on the project (eg. AFAIK JSP, xml files do so). I think this is controlled by FileEncodingQuery implementations
provided by editor support modules for those languages. Therefore I'm passing this on to sql editor folks.
As a quick solution I would suggest to change the encoding of the project where you have your SQL files to UTF-16.
Reassigned to new owner.
Could you attach sample UTF-16 file?
Created attachment 87615 [details]
Request SQL file in UTF-16 encoding as created by SQL Server Mgmt Studio
Added SQLFileEncodingQueryImpl which detects UTF-16 encoding.
Integrated into 'main-golden', will be available in build *200909181401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jiri Skrivanek <email@example.com>
Log: #156585 - Detect UTF-16 encoding for SQL files.