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 103895 - i18n character (Chinese in my case) destoried after reverting from '-J-Dfile.encoding=GBK'
Summary: i18n character (Chinese in my case) destoried after reverting from '-J-Dfile....
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Petr Pisl
URL:
Keywords: I18N
Depends on: 97850
Blocks:
  Show dependency tree
 
Reported: 2007-05-14 10:49 UTC by pzgyuanf
Modified: 2008-06-09 16:08 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The crashed file I've left it to stay here for a long time (2.53 KB, application/octet-stream)
2007-05-18 16:24 UTC, pzgyuanf
Details
the result after changed the encoding to utf8 in file properties dialog (2.21 KB, application/octet-stream)
2007-05-18 16:26 UTC, pzgyuanf
Details
the same result in NetBeans 6.0 M9 (29.77 KB, application/octet-stream)
2007-05-18 16:28 UTC, pzgyuanf
Details
the destroyed file: UsersRecorder (12.42 KB, application/octet-stream)
2007-06-18 05:13 UTC, pzgyuanf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pzgyuanf 2007-05-14 10:49:52 UTC
Because the doc explained this running command line parameter will resolve the the
problem of JSP file (it will use this encode instead of the default one utf8),

Then I tried to append '-J-Dfile.encoding=GBK'into etc/netbeans.conf file,
but I reverted it back (didn't set it at all) occasionally.

Finally, all my localized characters are destoried.
and I had to recover it by set the encode = GBK for these files one by one in
file properties dialog. 

that's to say, after reverting to the default encode (UTF8), the encode for the
files in my projects didn't change.
Comment 1 Marian Petras 2007-05-18 10:18:51 UTC
Reassigned to "projects" for evaluation - problem with file encoding.
Comment 2 Marian Petras 2007-05-18 12:38:46 UTC
An attempt to re-express the original report (correct me if I am wrong):


I had a problem with encoding of JSP files - I wanted to use the GBK encoding
for them but UTF-8 was used instead. In the documentation, I found that using a
command-line switch '-J-Dfile.encoding=GBK' should solve the problem so I tried
to use it (I put it to the etc/netbeans.conf file). Later (???) I reverted it back.

The result was that all my localized characters were destroyed. I fixed it by
setting file encoding (GBK) of JSP files manually, file by file.

After reverting back (how?, when?) to the default encoding (UTF-8), encoding of
the files in my project remained unchanged (compared with what?).

---

pzgyuanf, this bug should be fixed in NetBeans 6.0 M9. Could you check it? If
you still encounter the problem, could you describe it in other words, please?
Comment 3 pzgyuanf 2007-05-18 16:20:36 UTC
I'm sorry for my bad description before.

But I think you have got most parts of this problem.

Here is more clearly description (I hope so):

> Later (???) I reverted it back.
Yes, I reverted it back because I hope NetBeans should recover the destroyed text.


>After reverting back (how?, when?) to the default encoding (UTF-8), encoding of
>the files in my project remained unchanged (compared with what?).
Because I saw the text was destroyed, so I left the files opened and exited quickly.
Then removing the CMD switch I appended just now and restarted Nebeans.
The destroyed text still displayed as destroyed, this is why I said the files in
my project remained unchanged, they didn't get recover.
But actually, this is not true. Close the opened files then reopen them, they
really get back - display correctly exception only one file, you can see it in
my attachment.

Whatever operations I carried, it could not recover again. I remembered maybe
I've performed additional steps for the file during destroyed status. Such as
tried to set to other encoding in properties dialog (by right clicking the file
-> properties) or changed the default encoding for editor setting in Options
dialog (Tools | Options | Editing | Java Source -> Expert -> Default Encoding.


I'll farther research this problem and I'll let you know the result if I got any
result.


Hope I expressed clearly.

Thanks.


Comment 4 pzgyuanf 2007-05-18 16:24:50 UTC
Created attachment 42534 [details]
The crashed file I've left it to stay here for a long time
Comment 5 pzgyuanf 2007-05-18 16:26:02 UTC
Created attachment 42535 [details]
the result after changed the encoding to utf8 in file properties dialog
Comment 6 pzgyuanf 2007-05-18 16:28:20 UTC
Created attachment 42536 [details]
the same result in NetBeans 6.0 M9
Comment 7 Tomas Zezula 2007-05-28 15:16:01 UTC
The FileEncodingQuery is not yet supported in the web project (JSP) but it will
be in NB 6.0. It will (should) behave in this way:
1) You create web project
2) You set a project encoding in the project properties
3) All files you create in this project should have encoding you set in the
project customizer.

This issue depends on the FileEncodinQuery implementation in the web project,
issue #97850
Comment 8 pzgyuanf 2007-06-18 05:11:30 UTC
Can you recovery the ruined file in the attachment.
It's just FYI. and for test purpose.


thanks.
Comment 9 pzgyuanf 2007-06-18 05:13:06 UTC
Created attachment 43862 [details]
the destroyed file: UsersRecorder
Comment 10 Ken Frank 2007-06-18 15:38:36 UTC
I'm not sure the command line switch is really a supported one, and I think with the new file encoding
property of a project, that this might help the situation.

In M9, does it have in the properties of the web application, the value for the encoding of the project ?

Note - from what I've been told, the charset tag of jsp or html is used regardless of what the project encoding
is set to in project properties, for the jsp or html files, for designtime/editing/debugging/etc
(that is, not just for runtime)

Thus it might be that the encoding tag of each jsp might need to be changed separately; this part is still in progress.

---> Could you summarize what it is that you need to do in ide  and then can comment more about the solutions and
if this is an issue still ?

ken.frank@sun.com

Comment 11 pzgyuanf 2007-06-19 02:52:04 UTC
kfrank,

About the the charset tag for jsp or html, if the status will be as you said, in order to avoid to enter into the state
I have encountered, the command line switch '-J-Dfile.encoding=GBK' should be removed or at least deprecated. Then you
can close this bug.

This problem is cause by suddenness:
My friend ask me how to have the generated JSP/HTML file with:
<%@ page contentType="text/html;charset=GBK" %>
<%@page pageEncoding="GBK"%>

I told him you must wait for NB6 as I knew the encoding setting option in project properties dialog.
Or 
1. setting the default encode in Option | advance option | ...
2. changing the code template for Web | JSP 

Several day later, he told me he found one solution on NetBeans site, that's '-J-Dfile.encoding=GBK' command line switch,
which can change the whole encoding of the project.

Therefore, I have no doubt it and changed my netbeans.conf file then open one project and the problem appeared.
This is because the previous encode for my project is 'UTF8'.

Ok, that is.

---------------
This is my thought, 
If we can set the encoding for Web project and the generated JSP/HTML files inherit this encode, it would be fine.
Is there some stumbling block to implement as this?



Regards.

pprun
Comment 12 Ken Frank 2007-10-03 17:36:27 UTC
pprun,

can you try again with a recent nb6; there has been more project and file encoding handling
added now. also, now new jsp, html files are seeded with charset or page encoding value
of your current project encoding (see project properties) for new nb6 projects.

ken.frank@sun.com
Comment 13 Andrei Badea 2007-10-10 14:33:52 UTC
Probably fixed already, so closing. Please reopen with steps to reproduce in NetBeans 6.0 beta 1 or even a newer daily
build if still reproducible.
Comment 14 pzgyuanf 2007-10-24 05:17:11 UTC
Now the project can switch charsets back and forth and no text destroyed.
So if the project's default charset didn't correctly render the text, which has a different charset from the default
charset, I can change it and everything is done for me.  

BTW. Is there anyway to set the default charset for new project?
Currently, with the default installation, the OS platform default charset will be selected, for me GBK/GB18030 of
Chinese Windows XP.
But you known, we should use UTF-8 if we are participating in distribution / global development.
So in this case, we didn't want to change the selected default charset for project frequently.

Thanks

- pprun
Comment 15 Ken Frank 2007-10-24 05:26:29 UTC
good questions, let me try to answer some; here is your questions and my answers inside:

Now the project can switch charsets back and forth and no text destroyed.
So if the project's default charset didn't correctly render the text, which has a different charset from the default
charset, I can change it and everything is done for me.  

---> comment but remember that the project encoding affects all files in the project

also, java compiler can only use one encoding for compilation, so if some java files were created
in other encoding, and not changed, then there could be problems in compiling

and ide does not do autodetection or conversion of encodings

the user model is that someone might want to have entire new project using a different encoding
than encoding of locale they are in, or want to use utf-8 encoding even though their os might
not have such a locale.

but there is experimental/new module that will allow open or save in another chosen encoding
from ui choices, but not in product itself at this time but will be on update ctr.

BTW. Is there anyway to set the default charset for new project?
Currently, with the default installation, the OS platform default charset will be selected, for me GBK/GB18030 of
Chinese Windows XP.

---> the default charset for new projects is utf-8, not that of the encoding of the locale you are in when
running nb.

only way to set it is to change encoding of that or some other, perhaps non used project,
to the desired encoding; then all next created projects will use that encoding

it might be safer to have an unused project to change the encoding once, then create your
new projects; perhaps can be rfe to allow an option to set desired project encoding.

again, the user model here is that user would want to use same encoding for all projects

for pre nb6 projects, default project encoding property will be that of encoding user is in when run nb.
But you known, we should use UTF-8 if we are participating in distribution / global development.
So in this case, we didn't want to change the selected default charset for project frequently.

ken.frank@sun.com

Comment 16 kaa 2008-06-09 16:08:31 UTC
checked with trunk build 0608, ja locale: feq looks implemented now for Web Applications.
Also jsp and html files are seeded with encoding value obtained from project one.