Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » DSL file encoding
DSL file encoding [message #1121305] Mon, 30 September 2013 13:35 Go to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
Hi,

i'd like to have all DSL files for my language created by eclipse (i.e. *.mydsl) encoded in UTF-8. Eclipse encodes the files in the system's standard encoding.

I added the encoding statement to the Generator as described in the documentation:
Generator {
  encoding ="UTF-8"
  ...


My expectation was, that every newly created file will be encoded in UTF-8, but this isn't the case.

Any ideas what could have gone wrong?
Re: DSL file encoding [message #1121320 is a reply to message #1121305] Mon, 30 September 2013 13:50 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i think you have to implement a org.eclipse.xtext.parser.IEncodingProvider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: DSL file encoding [message #1121977 is a reply to message #1121320] Tue, 01 October 2013 05:41 Go to previous messageGo to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
I did implement a IEncodingProvider returning UTF-8 and bound it in the Runtime and the UiModule. The Runtime part works as expected. The standalone parser interprets the files as UTF-8.

But Eclipse still produces files encoded in the system default codepage.
Re: DSL file encoding [message #1122125 is a reply to message #1121977] Tue, 01 October 2013 08:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi how do you create the Files?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: DSL file encoding [message #1122131 is a reply to message #1122125] Tue, 01 October 2013 09:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
P.S: did you consider to change workspace encoding?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: DSL file encoding [message #1122205 is a reply to message #1122131] Tue, 01 October 2013 10:27 Go to previous messageGo to next message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
Creating files in Eclipse: select folder -> new -> file -> enter filename

That creates files in the default workspace encoding. Of course this can be changed by the user, but I'm looking for a way to set UTF-8 as default for my language's projects, so I don't have to tell the user to set his encoding.

Is this possible?

Re: DSL file encoding [message #1122216 is a reply to message #1122205] Tue, 01 October 2013 10:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

sorry i have no idea on that it is not an xtext specific problem.
if you use the project wizard you can create with

fragment = projectWizard.SimpleProjectWizardFragment auto-inject {
    		      generatorProjectName = "${projectName}"
    		 }

(dont forget to merge plugin.xml_gen)

i think you can customize the code to use utf-8 as encoding. (you have to digg into the code on that yourself)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: DSL file encoding [message #1122266 is a reply to message #1122216] Tue, 01 October 2013 11:37 Go to previous message
Robert Wild is currently offline Robert WildFriend
Messages: 33
Registered: August 2012
Member
I already toyed around with the SimpleProjectWizard, but it seemed like I need some time and a lot of know-how to get the projects the way I want them. I'll look into that.

Thanks
Previous Topic:Update Error for Xtext 4.2.3
Next Topic:NPE when serializing an in-memory model
Goto Forum:
  


Current Time: Thu Mar 28 18:26:05 GMT 2024

Powered by FUDForum. Page generated in 0.03512 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top