Specify the encoding of attached source files [message #1822021] |
Tue, 25 February 2020 22:50  |
Marc Walters Messages: 11 Registered: November 2019 |
Junior Member |
|
|
Hello everyone,
I am currently using Xtext (2.20.0.v20191202-1256) in Eclipse 2019-12 on macOS and experience issues related to the display of special characters in the attached source code. The default encoding of my workspace is set to UTF-8.
When I open an .xtend source file from the Xtext source packages, Eclipse interprets the encoding incorrectly. Jumping to the declaration of 'GeneratorFragment2', for instance, opens org.eclipse.xtext.xtext.generator.generator.GeneratorFragment2.xtend in an editor, but all the guillemets are shown as question marks (as REPLACEMENT CHARACTER, U+FFFD, to be more specific). Unfortunately, this also prevents Eclipse from parsing the enclosed code accordingly.
Setting the default encoding of the workspace to ISO-8859-1 and reopening the file solves the issue, but is not an option for the project that I am working on.
I have tried to set the encoding of the opened .xtend file to ISO-8859-1 via the Edit > Set Encoding dialog and to set the encoding of the org.eclipse.xtext.xtext.generator.source_2.20.0.v20191202-0915.jar source attachment to ISO-8859-1 (in the Java Build Path dialog). Both of these attempts do not seem to have any effect, though.
Is there anything I can do to let Eclipse know about the encoding of the attached .xtend source files?
Thanks!
[Updated on: Tue, 25 February 2020 22:52] Report message to a moderator
|
|
|
Re: Specify the encoding of attached source files [message #1822024 is a reply to message #1822021] |
Wed, 26 February 2020 01:12   |
|
I'm afraid that I do not see an option either. Xtend files in Xtext source are encoded with ISO-8859-1. Eclipse has no idea that those files should be opened with a different encoding than the workspace default. For files in projects you can specify their encoding on any resource.
It seems Eclipse ignores your setting on the source attachment. This may indicate a bug/missing feature in Eclipse Platform or JDT. This should be reproducible if you create some jar with files having a different encoding. If that is a repro, please file a bug to the JDT project.
|
|
|
|
Re: Specify the encoding of attached source files [message #1822034 is a reply to message #1822026] |
Wed, 26 February 2020 08:36   |
Marc Walters Messages: 11 Registered: November 2019 |
Junior Member |
|
|
Thank you for your answers. Although I would personally prefer to have everything encoded as UTF-8, wouldn't such a transformation create the reverse situation for people with their default encodings set to anything else than UTF-8?
I have just tried the 'Encoding' option of a source attachment for a JAR with just regular Java files. For these files, the option seems to work quite well: Despite my default workspace encoding set to UTF-8, Eclipse opens the source attachment as ISO-8859-1 if this is the value that I set the option to. Is it possible that .xtend files are just exempt from this? And could it be a suitable middle ground to make this affect .xtend files as well?
[Updated on: Wed, 26 February 2020 08:38] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02172 seconds