Bad encoding of JavaScript files

Having trouble installing Oxygen? Got a bug to report? Post it all here.
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Bad encoding of JavaScript files

Post by lukaseder »

Hello,

We've noticed that Oxygen causes our Cp1521-encoded JavaScript files to be displayed (and encoded) badly, always to UTF-8. Removing Oxygen from our plugins resolves the issue and displays JavaScript files correctly again.

All JavaScript editors are affected, including the normal text editor and the WTP JavaScript editor. It seems to be a setting for the general .js content type. I couldn't find such a setting in the preferences, though.

It seems as though Eclipse thinks that the JavaScript content is actually encoded that way. Everytime we save such a file, the actual encoding will be overwritten:

Image
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Re: Bad encoding of JavaScript files

Post by lukaseder »

We use <oXygen/> XML Editor 13.2, build: 2012013115
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Bad encoding of JavaScript files

Post by adrian »

Hello,

I have logged this problem to our issue tracking tool and we will investigate. We will notify you when a new version with the bugfix becomes available.

Meanwhile, you can easily get rid of this problem by editing the plugin.xml file from the Oxygen plugin directory and removing the oXygen JavaScript content type extension point.
If you have used the Eclipse update site, the Oxygen plugin folder is:
"<eclipse>/plugins/com.oxygenxml.editor_VV.V.0.vXXXXXXXXXX".
If you have used the zip distribution the plugin folder is located in:
"<eclipse>/dropins/com.oxygenxml.editor_VV.V.0.vXXXXXXXXXX/plugins/com.oxygenxml.editor_VV.V.0.vXXXXXXXXXX"
VV.V is the version and XXXXXXXXXX is the build number.

Edit the plugin.xml file and remove this section(search for "JsFile"):

Code: Select all

<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.text"
priority="low"
file-extensions="js"
id="JsFile"
name="oXygen JavaScript">
<describer class="com.oxygenxml.editor.editors.xml.XMLContentDescriber"/>
</content-type>
</extension>
Afterwards, make sure you run Eclipse at least once with the -clean command line argument.
e.g. eclipse.exe -clean

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Re: Bad encoding of JavaScript files

Post by lukaseder »

Thanks Adrian! That workaround did the trick for me
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Re: Bad encoding of JavaScript files

Post by lukaseder »

Note, in our distribution, the JsFile describer is actually a UTF8ContentDescriber:

Code: Select all


  <extension point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.text"
priority="low"
file-extensions="js"
id="JsFile"
name="oXygen JavaScript">
<describer class="com.oxygenxml.editor.editors.UTF8ContentDescriber"/>
</content-type>
</extension>
Maybe that's the problem?
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Re: Bad encoding of JavaScript files

Post by lukaseder »

... the same applies to CSS, and JSON files, btw
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Bad encoding of JavaScript files

Post by adrian »

The UTF8ContentDescriber was changed to XMLContentDescriber for all three types of files(CSS, JS, and JSON) in the latest maintenance build of Oxygen v13.2, 2012040515.

Update to the latest maintenance build and check if it makes any difference. Note that you will have to patch the plugin.xml again in case it doesn't.

You can download it here:
http://www.oxygenxml.com/download_oxyge ... os=Eclipse
or if you are using the Eclipse update site, you can simply update the plugin from Eclipse:
Help > Check for Updates

Let me know if it makes any difference.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
lukaseder
Posts: 19
Joined: Thu Feb 09, 2012 3:52 pm

Re: Bad encoding of JavaScript files

Post by lukaseder »

Hi Adrian,

Yes, upgrading to that maintenance release did the trick, too! Thanks a lot.

Cheers
Lukas
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Bad encoding of JavaScript files

Post by adrian »

Hi,

I'd just like to point out that even with the latest build, the Oxygen content describer will force the UTF-8 encoding for .js files when it can. It can do this if the files do not contain characters outside of the range of the UTF-8 encoding. This usually happens for all newly created .js files.

So, if you want to keep your chosen encoding(Cp1521) for all .js files(new or old), I still recommend editing the plugin.xml file and removing that section.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply