Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse character encoding problem(Eclipse automatically changes some characters with wrong ones.)
Eclipse character encoding problem [message #779691] Mon, 16 January 2012 10:34 Go to next message
Missing name Missing nameFriend
Messages: 7
Registered: December 2011
Junior Member
Hi,

Sorry if this have been discussed before, I could not find a solution to my particular problem.
I am using Eclipse Indigo V. 3.7.0

When I save a particualr file,the following error comes:

"Save could not be Completed
Reason:
Some characters cannot be mapped using "ISO-8859-1" character encoding.
Either change the encoding or remove the characters which are not supported by the "ISO-8859-1" character encoding
"
It tells me to save in UTF-8. If I save the file in UTF-8, then I have following problem when I see the changes in Clear-Case version control:

über became �ber
für became f�r
fr became f�r

The file is may be 10-15 years old, and may be was originally done in "ISO-8859-1", May be in the mean time some of the encoding are corrupted (like "fr", which should be "für"). The thing is, those are only in the comments, and I do not need to change them, but Eclipse changes them "Automatically". If I save the files with Code-Warrior or Notepad++. they are not changed automatically.
I have tried to save the file with US-ANSI, cp1252, UTF-8 also, with same result.

What I can change in EClipse so that it leaves those un-changed ? Or finds the correct encoding for, say "ü" ?

Thank you.




Re: Eclipse character encoding problem [message #779750 is a reply to message #779691] Mon, 16 January 2012 13:19 Go to previous messageGo to next message
Harry Houdini is currently offline Harry HoudiniFriend
Messages: 131
Registered: February 2010
Senior Member
What are Text file encoding setting in the Project Properties -> Resource page ?
Re: Eclipse character encoding problem [message #779756 is a reply to message #779750] Mon, 16 January 2012 13:43 Go to previous messageGo to next message
Missing name Missing nameFriend
Messages: 7
Registered: December 2011
Junior Member
Its the default "Inherited from container (ISO-8859-1)"
I guess it takes the default from the
Window -> Preferences -> Workspace -> Text file encoding.
I have also tested the Text file encoding with all others (US-ANSI, cp1252, UTF-8, UTF-16), with same results.

Is there a way to tell Eclipse that it should only save the DELTA in a changed file, and not the whole document?
Re: Eclipse character encoding problem [message #779787 is a reply to message #779756] Mon, 16 January 2012 15:05 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Your file is seems not to be encoded in ISO-8859-1. So when Eclipse loads the file with ISO-8859-1 encoding and then encounters a character that does not belong to this encoding it will fail. What can you do?
1) Open the file but do not edit it
2) In the main menu select Edit->Set Encoding... (this will change the encoding for the current file in the editor)
3) Choose e.g UTF-8
4) Are your umlauts still OK? If yes then try to edit the file and save it.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse character encoding problem [message #779819 is a reply to message #779787] Mon, 16 January 2012 16:13 Go to previous messageGo to next message
Missing name Missing nameFriend
Messages: 7
Registered: December 2011
Junior Member
Hi

Thanks for the reply.
If I first convert my encoding to ISO-8859-1 from Edit->Set Encoding, it seems to work after edit->save (though Eclipse adds many extra spaces and such). But it does not work at all if I convert to UTF-8.

In any case, I don't wanna convert the encoding for a 10+ years old project with >6000 files because of Eclipse, I hope there are other ways...Do you have any idea why Eclipse works differently than other Editors like Nothpad++, Codewright etc.? Can it simply save the DELTA, and not the entire file ?

Thanks.
Re: Eclipse character encoding problem [message #780141 is a reply to message #779819] Tue, 17 January 2012 09:04 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Missing name Mising name wrote on Mon, 16 January 2012 17:13
Hi

Thanks for the reply.
If I first convert my encoding to ISO-8859-1 from Edit->Set Encoding, it seems to work after edit->save (though Eclipse adds many extra spaces and such). But it does not work at all if I convert to UTF-8.

So when you set the default encoding in Window -> Preferences -> Workspace -> Text file encoding to ISO-8859-1 everything does work? I guess the extra spaces are caused by converting tabs to spaces. You can control this behavior in Window -> Preferences -> General->Editor->Text Editor
Also you may want to disable the save action to remove trailing white space Window -> Preferences -> C/C++->Editor->Save Actions



Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse character encoding problem [message #780560 is a reply to message #780141] Wed, 18 January 2012 15:59 Go to previous messageGo to next message
Missing name Missing nameFriend
Messages: 7
Registered: December 2011
Junior Member
Hi

If I change the following:
"Window -> Preferences -> Workspace -> Text file encoding -> ISO-8859-1", then Edit a file, it has the same problem, does not work.
It only works when I first do the convertion, and then Edit->save.
Seems strange to me, any ideas ?

Thanks.
Re: Eclipse character encoding problem [message #780584 is a reply to message #780560] Wed, 18 January 2012 17:10 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
Did you set any encoding In Window -> Preferences ->General->Content types ?
Did you close and then reopen the file after changing the encoding in Window -> Preferences -> Workspace -> Text file encoding ?


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse character encoding problem [message #780730 is a reply to message #780584] Thu, 19 January 2012 08:55 Go to previous messageGo to next message
Missing name Missing nameFriend
Messages: 7
Registered: December 2011
Junior Member
Hi,

You were right, I must close and then reopen the file after changing the encoding in Window -> Preferences -> Workspace -> Text file encoding (although I tested with Closing->reopening the whole workspace!). Now it works.
Also, now I have no spaces in clearcase checked-out files,safter I removed trailing white space in Window -> Preferences -> C/C++->Editor->Save Actions. I think the general recommendation is to remove trailing whites, but in this case its better not to do this, dont know why!
I have no encoding in Window -> Preferences ->General->Content types .

Thank you for your time and valuable tips.
Re: Eclipse character encoding problem [message #883665 is a reply to message #780141] Sat, 09 June 2012 03:05 Go to previous messageGo to next message
AM Desai is currently offline AM DesaiFriend
Messages: 1
Registered: June 2012
Junior Member
I am new to the character encoding issue in Eclipse. But i was not able to a make a change and save a (php) .module file because of an error involving the cp1252 encoding. i saw this post and changed it to ISO-8859-1, closed the file, re-opened it and everything appears to work now. so, first off, i thank for the useful feedback.

Can anybody explain to me what the deal with the character encoding is? I hope changing it from cp1252 to iso8859 will not break something else down the line..

thanks,

[Updated on: Sat, 09 June 2012 03:06]

Report message to a moderator

Re: Eclipse character encoding problem [message #1006851 is a reply to message #883665] Sat, 02 February 2013 22:11 Go to previous message
Julio Mising name is currently offline Julio Mising nameFriend
Messages: 3
Registered: December 2010
Junior Member
The environment variable need to be set in the Eclipse preferences window under C/C++/Build/Environment. You need to add a new variable by clicking on the Add button. The variable name should be set to LANG and the value to en_US.ISO-8859-1
Previous Topic:Issues on Eclipse Semantic Checker
Next Topic:CDT on windows using mingw
Goto Forum:
  


Current Time: Fri Dec 19 10:06:47 GMT 2014

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

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