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 167430 - When I compare files with Diff to..., the second file is opened in wrong codepage
Summary: When I compare files with Diff to..., the second file is opened in wrong code...
Status: NEW
Alias: None
Product: utilities
Classification: Unclassified
Component: Diff (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Ondrej Vrabec
Depends on:
Reported: 2009-06-21 21:11 UTC by rudyment
Modified: 2014-06-05 12:15 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description rudyment 2009-06-21 21:11:38 UTC
I use in all my project the code page UTF-8. When I want to compare a file with a similar one by the funtion Dif To...,
the second file is not opened in the correct code-page. I expect, that it is openec in Win 1250. I have to close the
IDE, open the previous version (6.5) and perform the comparing in that version.
Comment 1 Vitezslav Stejskal 2009-06-22 12:06:17 UTC
What project does the second file belong to? AFAIK files are opened with the encoding specified by the project owning
that file. And if no such project exists the system default encoding is used. Could you please be more specific about
the projects and files that you are using? Thanks
Comment 2 rudyment 2009-06-22 14:14:52 UTC
It is only another package in the same project. I prepare a series of programs for students. Each package for one
lesson. I needed to compare two versions in different packages.

However, as I said, in NetBeans 6.5 it works fine.

By the way: I thing it would be fine to be able to set the codepage of the file out of project. E.g. I work on Windows
and I have almost no file in the windows' native 1250 codepage.
Comment 3 Jiri Prox 2009-08-19 15:11:18 UTC
I can reproduce it as well, but it seems that in 6.5 it worked only "by accident"

Here are steps I've done:
1) create new project, UTF-8 encoding
2) create new class and type accented letters
3) switch to win-1250
4) create new class and type accented letters
5) close both files
6) use 'diff' 
-> in 6.5 both files are opened in correct encoding (probably the 1st document is cached somewhere, it was opened while
project was set to utf- 8)

-> in dev build both files has wrong encoding

7) open both files
8) use diff
-> 6.7 and dev: one file is opened correctly (it's encoding matches project encoding) the another has problems with accents 

Comment 4 Vitezslav Stejskal 2010-03-05 05:57:55 UTC
In general mixing up files with different encoding in the same project is not supported. However, there are file types that support file-level encoding (eg. XML, HTML, JSP, ...). Unfortunately, majority of file types have no way of supplying text encoding.
Comment 5 rudyment 2010-03-05 10:51:40 UTC
The problem si, that all my files are encoded in UTF-8, however NB uses this encoding only for files incorporated in the projects with this encoding set.

It would be fine, to be able to tell NB, that for all files, even that ones openend directly from random part of the disk, my default encoding is the UTF-8 independently on the encoding preferred by the OS in use.
Comment 6 Michel Graciano 2010-03-05 11:32:41 UTC
Did you tried to start the IDE with different enconding than OS default? Maybe -Jfile.encoding=UTF-8 parameter could help you.

Comment 7 Vitezslav Stejskal 2010-03-08 05:49:08 UTC
(In reply to comment #6)
> Did you tried to start the IDE with different enconding than OS default? Maybe
> -Jfile.encoding=UTF-8 parameter could help you.

The switch is -J-Dfile.encoding=UTF-8 and you can either use it on the command line or add it to your <nb-inst>/etc/netbeans.conf file. It will change the default encoding on the JVM-level. You can double check that the default encoding was indeed changed by looking at the Netbeans -> About dialog or in <ide-userdir>/var/log/messages.log file.