Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Text file encoding and guillemets
Text file encoding and guillemets [message #684642] Thu, 16 June 2011 00:59 Go to next message
Akira Tanaka is currently offline Akira TanakaFriend
Messages: 98
Registered: March 2010
Member
When created, a sample domain model project is configured using ISO-8859-1 as text file encoding. If I changed this to UTF-8, the french quotation marks or guillemets (of rich strings) are shown on the screen like the following.

�val importManager = new ImportManager(true)�


So, If I needed to work in UTF-8 (this is always the case with me), I need to change every part of the xtend files manually.

«val importManager = new ImportManager(true)»


Is there any convenient way to change the encoding? I found it possible to copy the souce code in memory by "select-all with control-C" in ISO-8859-1 then after swithing to UTF-8 it can be pasted in UTF-8, but this takes time if there are many xtend files defined in the generator.

Thanks for your help in advance.
Akira
Re: Text file encoding and guillemets [message #684715 is a reply to message #684642] Thu, 16 June 2011 05:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Akira

It is probably easiest to set the Resource preferences for your Project
preferrences to UTF-8. (Right button contexr menu after selecting the
project).

You will then get a .settings/org.eclipse.core.resources.prefs file
containing

#Sun May 29 07:31:58 BST 2011
eclipse.preferences.version=1
encoding/<project>=UTF-8

which you should put in CVS so that your colleagues share the preference.

Regards

Ed Willink

On 16/06/2011 01:59, Akira Tanaka wrote:
> When created, a sample domain model project is configured using
> ISO-8859-1 as text file encoding. If I changed this to UTF-8, the
> french quotation marks or guillemets (of rich strings) are shown on
> the screen like the following.
>
> �val importManager = new ImportManager(true)�
>
> So, If I needed to work in UTF-8 (this is always the case with me), I
> need to change every part of the xtend files manually.
>
> «val importManager = new ImportManager(true)»
>
> Is there any convenient way to change the encoding? I found it
> possible to copy the souce code in memory by "select-all with
> control-C" in ISO-8859-1 then after swithing to UTF-8 it can be pasted
> in UTF-8, but this takes time if there are many xtend files defined in
> the generator.
>
> Thanks for your help in advance.
> Akira
Re: Text file encoding and guillemets [message #684756 is a reply to message #684715] Thu, 16 June 2011 07:34 Go to previous messageGo to next message
Akira Tanaka is currently offline Akira TanakaFriend
Messages: 98
Registered: March 2010
Member
Hello Ed,

Thank you for the response.

I think ".settings/org.eclipse.core.resources.prefs file" is created per project, and so in case for my starting a new Xtext project this will work. But, that does not solve my issue. My issue is about handling of a sample domain model project (and others) shipped with Xtext 2.0(RC4, and probably true to the previous ones). This sample domain project is configured for ISO-8859-1, so if I create a new sample domain model project from File->New->Xtext Domain-Model Example, the source code introduced (including guillemets) looks fine regardless of the workspace's encoding setting. However, if I changed the project's encoding to UTF-8, the issue I described in the firs message will occur. And, I guess there are many Xtext projects found in Xtext Community page configured in the same way. I would hope Xtext team consider switching the default encoding from ISO-8859-1 to UTF-8, but if there is an easy way to handle this, that would be a great help.

Akria
Re: Text file encoding and guillemets [message #684759 is a reply to message #684756] Thu, 16 June 2011 07:40 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

there are command line tools for converting files from one encoding to another (batch mode).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: Text file encoding and guillemets [message #684764 is a reply to message #684642] Thu, 16 June 2011 07:47 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Akira,

you could write a small plugin that allows to bulk-change the encoding
of files (basically automating the "copy change-encoding paste" step.
Thinking about it, something like this could already exist in the
eclipse universe.

Why do you need a specific encoding on the sample projects?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 16.06.11 02:59, schrieb Akira Tanaka:
> When created, a sample domain model project is configured using
> ISO-8859-1 as text file encoding. If I changed this to UTF-8, the french
> quotation marks or guillemets (of rich strings) are shown on the screen
> like the following.
>
> �val importManager = new ImportManager(true)�
>
> So, If I needed to work in UTF-8 (this is always the case with me), I
> need to change every part of the xtend files manually.
>
> «val importManager = new ImportManager(true)»
>
> Is there any convenient way to change the encoding? I found it possible
> to copy the souce code in memory by "select-all with control-C" in
> ISO-8859-1 then after swithing to UTF-8 it can be pasted in UTF-8, but
> this takes time if there are many xtend files defined in the generator.
>
> Thanks for your help in advance.
> Akira
Re: Text file encoding and guillemets [message #684780 is a reply to message #684764] Thu, 16 June 2011 08:28 Go to previous message
Akira Tanaka is currently offline Akira TanakaFriend
Messages: 98
Registered: March 2010
Member
Hello Alex and Sebastian,

Thank you very much for the responses and comments. Sometimes I need this to demonstrate that Xtext, including the sample project and others, is actually usable under our language environment with our characters. It's a kind of impressing to show/see Xtext working with our language characters. Actually a sample domain model is not hard to modify since its size is small. I hate dealing with bigger example projects, though.

Best,
Akira
Re: Text file encoding and guillemets [message #684801 is a reply to message #684764] Thu, 16 June 2011 08:22 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Sebastian

I think you're missing the problem.

Certainly a plugin can be used to convert wrong files. But here the
problem is that the files are 'correct' but behave wrong.

The root of the problem is that the default Eclipse workspace encoding
is different for Linux and Windows so guilemet files are not portable
until the consumer sets their file/project encoding preferences to match
the producer, which is also not possible for default Linux/Windows
encodings since adequate default codings are not mutually available.

It is best to use one of UTF-8 or UTF-16. If there are only a few
non-ASCII characters the occasional UTF-8 inefficiency is acceptable. If
there are many non ASCII characters UTF-16 might be sensible.

[It is unhelpful that itemis' Xtend projects do not all have UTF-8 as a
distributed project preference; Checking out Xtend from Git gives
guilemet errors on Windows.]

Regards

Ed Willink



On 16/06/2011 08:47, Sebastian Zarnekow wrote:
> Hi Akira,
>
> you could write a small plugin that allows to bulk-change the encoding
> of files (basically automating the "copy change-encoding paste" step.
> Thinking about it, something like this could already exist in the
> eclipse universe.
>
> Why do you need a specific encoding on the sample projects?
>
> Regards,
> Sebastian
Previous Topic:Xtext editor integration
Next Topic:Duplicate Names Across Files
Goto Forum:
  


Current Time: Fri Apr 26 19:05:45 GMT 2024

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

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

Back to the top