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.
Summary: | i18n character (Chinese in my case) destoried after reverting from '-J-Dfile.encoding=GBK' | ||
---|---|---|---|
Product: | javaee | Reporter: | pzgyuanf <pzgyuanf> |
Component: | Code | Assignee: | Petr Pisl <ppisl> |
Status: | VERIFIED FIXED | ||
Severity: | blocker | CC: | kaa, kfrank, mpetras |
Priority: | P3 | Keywords: | I18N |
Version: | 5.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 97850 | ||
Bug Blocks: | |||
Attachments: |
The crashed file I've left it to stay here for a long time
the result after changed the encoding to utf8 in file properties dialog the same result in NetBeans 6.0 M9 the destroyed file: UsersRecorder |
Description
pzgyuanf
2007-05-14 10:49:52 UTC
Reassigned to "projects" for evaluation - problem with file encoding. 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? 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. Created attachment 42534 [details]
The crashed file I've left it to stay here for a long time
Created attachment 42535 [details]
the result after changed the encoding to utf8 in file properties dialog
Created attachment 42536 [details]
the same result in NetBeans 6.0 M9
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 Can you recovery the ruined file in the attachment. It's just FYI. and for test purpose. thanks. Created attachment 43862 [details]
the destroyed file: UsersRecorder
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 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 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 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. 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 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 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. |