Skip to main content



      Home
Home » Modeling » TMF (Xtext) » DSL file encoding
DSL file encoding [message #1121305] Mon, 30 September 2013 09:35 Go to next message
Eclipse UserFriend
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 09:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i think you have to implement a org.eclipse.xtext.parser.IEncodingProvider
Re: DSL file encoding [message #1121977 is a reply to message #1121320] Tue, 01 October 2013 01:41 Go to previous messageGo to next message
Eclipse UserFriend
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 04:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi how do you create the Files?
Re: DSL file encoding [message #1122131 is a reply to message #1122125] Tue, 01 October 2013 05:00 Go to previous messageGo to next message
Eclipse UserFriend
P.S: did you consider to change workspace encoding?
Re: DSL file encoding [message #1122205 is a reply to message #1122131] Tue, 01 October 2013 06:27 Go to previous messageGo to next message
Eclipse UserFriend
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 06:38 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: DSL file encoding [message #1122266 is a reply to message #1122216] Tue, 01 October 2013 07:37 Go to previous message
Eclipse UserFriend
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 Jul 03 19:22:08 EDT 2025

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

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

Back to the top