This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 255660 - Encoding change renders properties file unusable
Summary: Encoding change renders properties file unusable
Status: NEW
Alias: None
Product: utilities
Classification: Unclassified
Component: Properties (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-02 11:48 UTC by Peter Nabbefeld
Modified: 2015-10-07 06:01 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Nabbefeld 2015-10-02 11:48:01 UTC
I've created a java project (maven java application) using UTF-8 with NB8.02, project encoding UTF-8, properties file using UTF-8, too.

1. Already with 8.02, the file has been added as if it has default windows encoding.
2. With 8.02, I had to change encoding to "project encoding", that was all to get it working.
3. After switching to 8.1Beta, the file was no longer assigned "project encoding" - why? => First bug
4. After switching on "project encoding", the file was corrupted: Each single byte of the UTF-8 codes has been turned into a single character, corrupting all non-ascii characters. => Second bug

So, there're two bugs:
1. File properties are not passed to the new installation (probably a change in project.xml or project.properties?)
2. File encoding change corrupts characters.
Comment 1 Peter Nabbefeld 2015-10-02 11:50:52 UTC
Might be related to #166597
Comment 2 Tomas Zezula 2015-10-05 09:52:13 UTC
Problem 1) Maven project. But I think that the properties file should not use project encoding as the properties file encoding is either ISO-8859-1 or UTF-8 (1.5+) by spec.

Problem 2) In fact it's not a bug. When the file was created in Encoding1 and switched to incompatible Encoding2 the bytes to character mapping may produce garbage. The change of encoding in the project changes how the files are loaded and stored it does not recode any existing files.
Comment 3 Peter Nabbefeld 2015-10-05 10:19:41 UTC
Hi Tomas,

it seems, there has sth. changed from 8.0 to 8.1 - probably unintendedly. I could change encoding in 8.0 without corruption, the same did not work for me with 8.1. In the meantime, I got the same problem with *.java files, which I copied from a windows-1252-encoded project to one with utf-8-encoding, so (2) is not true.

Concerning (1), I wouldn't have changed econding to project one's, if I wouldn't have had a project with utf-8-encoding, but it had been recognized as using platform encoding.
Comment 4 Peter Nabbefeld 2015-10-05 10:28:55 UTC
Em, sorry, last sentence is not well understandable - I wanted to say:
"... but the _properties file_ had been recognized as using platform encoding."
Comment 5 Tomas Zezula 2015-10-05 16:36:14 UTC
I was trying to reproduce and everything works fine in default set up.
The properties file correctly returns ISO-8859-1 encoding according to spec.
The situation changes when you check File Properties/Use Project Encoding. The option is strange as according to spec the properties file can be either ISO-8859-1 or UTF-8. Properties file encoded in other encoding is not a valid properties file.

The option is stored as FileObject attribute which is lost during IDE update, if you turn it on you need to do it again in the new installation.

The issue is not project related, reassigning.
Comment 6 Tomas Zezula 2015-10-05 16:43:45 UTC
Hi Peter,
regarding the (2) and Java. The IDE never did any file updates when you changed the encoding. Aren't you using "Open In Encoding Plugin" this plugin assigns an explicit encoding to given file which is then enforced. But it's saved in FileObject attribute and has the same problem as the properties file.

Can you attach some java file which works in NB 8.0 but not in NB 8.1. I will debug it.
If you have both Nb 8.0 and 8.1 you can also run the IDE with -J-Dorg.netbeans.api.queries.FileEncodingQuery.level=FINE and open such a file. The log after opening the file should be similar.
Thanks
Comment 7 Tomas Zezula 2015-10-06 15:20:34 UTC
Hi Peter,
had you a time to look for an affected java file?
I want to be sure that the issue is not generic before we release NB 8.1.
Thanks a lot.
Comment 8 Peter Nabbefeld 2015-10-07 06:01:08 UTC
Sorry, I'll not have enough spare time before tomorrow