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 164644

Summary: Character encoding problem after using Replace in Projects
Product: utilities Reporter: styu_ <styu_>
Component: SearchAssignee: Jaroslav Havlin <jhavlin>
Status: RESOLVED WORKSFORME    
Severity: blocker CC: hair, tmysik
Priority: P3    
Version: 7.0   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Bug Depends on: 201869    
Bug Blocks:    
Attachments: step1
screens+log
testcase
File before using Replace in Projects command
File after using Replace in Projects command

Description styu_ 2009-05-06 23:15:40 UTC
I am using UTF-8 encoded source files. After using 'Replace in Projects', NetBeans (Build 200905051401) sometimes 
improperly using ascii encoding after replacing (the replace itself is fine), so the UTF-8 characters shows ugly in the 
editor. When the problem occurs, the only solution is to exit the IDE, and re-start it (closing the file and re-opening it 
not solves the problem).
Comment 1 Vitezslav Stejskal 2009-05-07 10:23:28 UTC
Could you please describe in steps what you do so that we can replicate the problem? Also please attach your
<ide-userdir>/var/log/messages.log file. Thanks
Comment 2 styu_ 2009-05-07 13:10:19 UTC
Created attachment 81728 [details]
step1
Comment 3 styu_ 2009-05-07 13:13:44 UTC
Created attachment 81729 [details]
screens+log
Comment 4 styu_ 2009-05-07 13:19:00 UTC
I can not replicate the error (it firstly occurred weeks ago, and this is the second case), but I am attached screenshots 
from the error, hope this helps.
Comment 5 Jiri Prox 2009-05-11 10:28:12 UTC
thanks for screen shots
Comment 6 Vitezslav Stejskal 2009-05-11 10:39:39 UTC
Thanks for the files and your info, but I'm afraid that without being able to reproduce this we will not be able to fix it.
Comment 7 styu_ 2009-05-27 12:23:24 UTC
Today I used the 'Replace In Projects' function again, and the first impression was that everything is okay. But after 
closed the files, and reopened them, I recognized that Netbeans saved the files in ansi encoding, not in UTF-8.

An other problem is, when opening a file from 'Include Path', Netbeans opens them as ANSI, not UTF-8, so the problem may 
be there (two project was open when replacing, but one of them is in the Include Path of the other project).
Comment 8 styu_ 2009-11-19 02:14:19 UTC
Created attachment 91314 [details]
testcase

I have created a testcase, it seems to be reproducing the error 100% of the cases.
I am on Windows XP SP3.

Unzip to C:\ root folder. It creates two php projects, and a directory with the two NB projects. One of the php projects is a framework, and the error is related to the include path.

1. Open the project (and only that project) utf8_test_project
2. Ctrl+click on '::world()'

Result: hello.class.php opens with strange characters.

3. Close the file 'hello.class.php'
4. Close and reopen NB.
5. Open the project 'utf8_test_project_framework' (leave open the other project too)
6. Ctrl+click on '::world()'

Result: OK (it's still OK, after restarting NB)

7. Close 'hello.class.php' and 'index.php'
8. Close the project 'utf8_test_project_framework' 
9. Restart NB
10. Open index.php, and ctrl+click on 'world()'

Result: strange characters again
Comment 9 Vitezslav Stejskal 2009-11-20 03:31:40 UTC
Thanks for the testcase. I'll try to reproduce the problem on my laptop and see if we can find what's going wrong. In the meantime CCing tmysik, who could know offhand how FileEncodingQuery works for (closed) PHP projects.
Comment 10 Vitezslav Stejskal 2009-11-20 06:35:02 UTC
Umm, it seems to be working fine in my 6.8dev build. Could you please try this in some of the later 6.8 builds? If this is fixed in 6.8, but you still need to use 6.7 for some reason, I think you could work around this issue by adding -J-Dfile.encoding=UTF8 to your <nbinst>/etc/netbeans.conf among the netbeans_default_options=. This option will set the default encoding at the JVM level (eg. IDE wide) to UTF8. You can verify that the setting works by looking at the Help -> About dialog, which shows the default encoding and locale used by the IDE.
Comment 11 styu_ 2009-11-20 06:53:40 UTC
(In reply to comment #10)

Thanks for the workaround, it is fixing the issue!

Product Version: NetBeans IDE Dev (Build 2009-11-19_09-04-03 )
Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01
System: Windows XP version 5.1 running on x86; UTF8; hu_HU (nb)
Userdir: C:\Documents and Settings\Styu\.netbeans\dev

(before the fix, it was Cp1250)
Comment 12 Vitezslav Stejskal 2010-03-05 06:10:45 UTC
I assume that this has been fixed long time ago and is no longer a problem. If that's not correct (ie. can still be reproduced in recent 6.9dev builds), please reopen. Thanks
Comment 13 maxceem 2010-11-24 10:35:41 UTC
Created attachment 103274 [details]
File before using Replace in Projects command
Comment 14 maxceem 2010-11-24 10:37:03 UTC
Created attachment 103275 [details]
File after using Replace in Projects command
Comment 15 maxceem 2010-11-24 10:50:09 UTC
I use NetBeans IDE 7.0 Beta (Build 201011152355) now I'm not sure may I change NetBeans version in the ticket or no and I'm not sure is it good to continue this ticket or it's better to create a new one but nevertheless I have similar bug in 7.0 beta.

What is the bug:
When I use Replace in Projects comman
all russian text which was in cp1251 became ???? ???? ??????
in the top of html file disappears some quite big part about 117 lines!!!!

How to reproduce this bug:
1. Create a new project with "File before using Replace in Projects command" (attached) inside, make sure that encoding of this project is setted to cp1251 and set it as a Main Project.
2. Open Replace in Projects dialog and enter 
as containg text: id="menu_main"
as replace with: class="menu_main"
Set scope to Main Project and press Find.
After getting list with search results press Replace button and you will get "File after using Replace in Projects command" (attached).
Comment 16 styu_ 2010-11-25 22:52:10 UTC
I have just re-ran my old test-case on Netbeans 7.0 Beta OS Independent ZIP version (PHP only) with default settings, and I got the same error as before (on the first run). However with the -J-Dfile.encoding=UTF8 config parameter everything is fine.

Product Version: NetBeans IDE 7.0 Beta (Build 201011152355)
Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01
System: Windows XP version 5.1 running on x86; Cp1250; hu_HU (nb)
Userdir: C:\Documents and Settings\Styu\.netbeans\7.0beta

My OS is Windows XP SP3 Hungarian (the same installation as before, but I will test it on an other PC tomorrow).
Comment 17 styu_ 2010-11-26 07:05:10 UTC
I have ran my test-case on an other PC, and the same issue here (on the first run, so it's 100% reproducible).
You need only the first two step to see the error, so there is no need to restart NetBeans at all (just uncompress the zipped NetBeans, run it and open the `utf8_test_project` only).

Product Version: NetBeans IDE 7.0 Beta (Build 201011152355)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86; Cp1250; hu_HU (nb)
Userdir: C:\Documents and Settings\István\.netbeans\7.0beta

XP SP3 Hungarian
Comment 18 asdoso 2011-07-04 14:18:22 UTC
I'm on Windows 7 SP1, Italian version and I have this problem too.

Very annoying, I'm writing a PHP project and I have a lot of characters like è, à, ù, ò and they all get messed up when I replace a word using the Replace feature, and even worse with the Replace In Project one.
Comment 19 dagguh 2011-07-06 18:09:19 UTC
I am suffering from the same bug.

The project default encoding is ISO-8859-2 but my Selenium tests are encoded in UTF-8. The Selenium tests show 2 characters instead of a single UTF-8 one, but thats okay, the editor is obeying the Project Defaults.

When I use Replace in Projects on my Selenium tests, those pairs of characters are converted to a single question mark. This pretty much screws up my Selenium tests. I'm not even replacing these encoded characters. I'm only replacing ANSI strings.

Some of my XML files contain Polish characters. XMLs are encoded in ISO-8859-2 so they are displayed correctly. However, if I use Replace in Projects, the output XML is getting cut on the first occurrence of a Polish character. I even specify encoding in the XML document itself via <?xml version="1.0" encoding="ISO-8859-2"?> but I assume it doesn't and shouldn't affect the Replace in Projects feature.
Comment 20 Jaroslav Havlin 2011-09-14 06:50:58 UTC
I can only reproduce encoding problems with XML files, other file types work fine for me.
Problems with XML are described in bug 201869.
Comment 21 Jaroslav Havlin 2011-09-19 10:06:03 UTC
Works well in current daily build (201109180600).
Please reopen if any encoding problems occur again.