Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342925 - [javadoc wizard] Pass project's encoding to -charset and -encoding when generating Javadoc
Summary: [javadoc wizard] Pass project's encoding to -charset and -encoding when gener...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-15 03:42 EDT by Harendra CLA
Modified: 2011-04-20 10:22 EDT (History)
6 users (show)

See Also:


Attachments
Test project (2.73 KB, application/zip)
2011-04-15 03:46 EDT, Harendra CLA
no flags Details
Project with generated docs (28.06 KB, application/zip)
2011-04-17 22:12 EDT, Harendra CLA
no flags Details
Browser preferences page (79.60 KB, image/png)
2011-04-17 22:13 EDT, Harendra CLA
no flags Details
Reference for eclipse 3.6 (163.63 KB, image/png)
2011-04-20 03:28 EDT, Harendra CLA
no flags Details
Eclipse 3.6 Browser preference page (86.20 KB, image/png)
2011-04-20 03:50 EDT, Harendra CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harendra CLA 2011-04-15 03:42:31 EDT
Build Identifier: I20110407-2200

Eclipse version:I20110407-2200
OS: Ubuntu Linux 10.10
Java Version: JRE 1.6.0 IBM Linux build pxi3260sr9fp1-20110208_03 (SR9 FP1)
Locale: ja_JP.utf8

Reproducible: Always

Steps to Reproduce:
1.Import the attached project or create a project with either the class or the method name containing DBCS characters.
2.Click on the project, Project->Generate Javadocs.
3.Go to Window->Preferences->General->Webbrowser and select Use internal web browser radio button and check "Default system web browser".
4. Now click on the class name containing dbcs character in Java editor.
5. Click Navigate->Open Attached Javadoc.
6. The text will be shown all garbled.
This could be due to the fact that the Javadoc does not have a meta tag that
specifies the document is encoded in UTF-8. The project had encoding set to UTF-8. This bug however has a workaround. If you set your browser to External web browser and choose Firefox, the text will be displayed correctly.
Comment 1 Harendra CLA 2011-04-15 03:46:10 EDT
Created attachment 193329 [details]
Test project
Comment 2 Dani Megert CLA 2011-04-15 06:45:58 EDT
Can you try this:
1. generate the files into the project
2. try to open the generated HTML directly out of the Package Explorer
==> does that work?

Do you know which browser is used as internal browser?

Also, please attach the generated files.

NOTE: You can set the encoding on the project. When doing so, it's easier for us to import the project.
Comment 3 Harendra CLA 2011-04-17 22:05:24 EDT
(In reply to comment #2)
> Can you try this:
> 1. generate the files into the project
> 2. try to open the generated HTML directly out of the Package Explorer
> ==> does that work?
> 
> Do you know which browser is used as internal browser?
> 
> Also, please attach the generated files.
> 
> NOTE: You can set the encoding on the project. When doing so, it's easier for
> us to import the project.

No it does not work that way either. I dont know what browser eclipse is using
by default. My best guess is some swt based browser. Please let me stress this fact again, there is no encoding error during javadoc generation. The internal browser is only setting wrong encoding during display. I am 100% sure, this is 
due to missing encoding tag. If you add following line to the generated html
it works fine.
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
So I think there is some kind of encoding detection problem.
Comment 4 Harendra CLA 2011-04-17 22:12:44 EDT
Created attachment 193453 [details]
Project with generated docs
Comment 5 Harendra CLA 2011-04-17 22:13:16 EDT
Created attachment 193454 [details]
Browser preferences page
Comment 6 Markus Keller CLA 2011-04-19 09:56:21 EDT
We don't control the Javadoc generation -- we just call the javadoc executable. So we can't influence whether the doc gets a meta tag.

But we could maybe use Browser#setUrl(String, String, String[]) and set the charset of the enclosing project via the 'headers' parameter.
Comment 7 Dani Megert CLA 2011-04-19 10:56:08 EDT
On my non-UTF-8 Windows system the files display correctly in the internal and external Web browser. I suspect that on your system the encoding of the internal browser is wrong or its auto-detection is not good enough (check context menu > Encoding). This is not a bug of Eclipse.

>We don't control the Javadoc generation -- we just call the javadoc executable.
>So we can't influence whether the doc gets a meta tag.
That's not true: we could pass the project's encoding when generating the Javadoc via -charset option which adds the charset meta data to the HTML files.

There were also bugs that the generation failed completely because the source files could not even be read (see e.g. bug 223177). We should pass -encoding and -charset of the project to the javadoc tool.
Comment 8 Harendra CLA 2011-04-19 22:57:42 EDT
(In reply to comment #6)
> We don't control the Javadoc generation -- we just call the javadoc executable.
> So we can't influence whether the doc gets a meta tag.
> 
> But we could maybe use Browser#setUrl(String, String, String[]) and set the
> charset of the enclosing project via the 'headers' parameter.
This function is working properly under Eclipse 3.6 so this could be a 
regression bug. These days any modern browser can guess the best possible
encoding these days so even without the meta-tag it should be possible to 
view the DBCS content correctly. I am not sure why the browser is using
other encoding despite the default system encoding being UTF-8.
Comment 9 Dani Megert CLA 2011-04-20 01:47:01 EDT
> This function is working properly under Eclipse 3.6
Are you 100% sure? Is it with the same workspace or a different one?
Comment 10 Harendra CLA 2011-04-20 03:28:53 EDT
Created attachment 193658 [details]
Reference for eclipse 3.6
Comment 11 Harendra CLA 2011-04-20 03:30:38 EDT
(In reply to comment #9)
> > This function is working properly under Eclipse 3.6
> Are you 100% sure? Is it with the same workspace or a different one?

Ya please check the screenshot. However it was under different workspace,
the javadoc was produced within that workspace as well. I checked html code
there is no metadata mentioning utf-8. The DBCS characters are showing
correctly.
Comment 12 Dani Megert CLA 2011-04-20 03:32:32 EDT
> However it was under different workspace,
> the javadoc was produced within that workspace as well. I checked html code
> there is no metadata mentioning utf-8. The DBCS characters are showing
> correctly.
But if you take the same workspace with each Eclipse version, is the behavior different?
Comment 13 Harendra CLA 2011-04-20 03:48:36 EDT
(In reply to comment #12)
> > However it was under different workspace,
> > the javadoc was produced within that workspace as well. I checked html code
> > there is no metadata mentioning utf-8. The DBCS characters are showing
> > correctly.
> But if you take the same workspace with each Eclipse version, is the behavior
> different?
Just confirmed, yes eclipse 3.6 can indeed open the problematic document without
any problems. I will include settings too as it seems to be slightly different compared
to 4.1. Either way I used default settings.
Comment 14 Harendra CLA 2011-04-20 03:50:31 EDT
Created attachment 193659 [details]
Eclipse 3.6 Browser preference page
Comment 15 Dani Megert CLA 2011-04-20 03:51:03 EDT
> Either way I used default settings.
What do you mean by "settings"? If you try with the identical workspace then no settings should be affected.

Also, could you please try with 3.7 (e.g. M6)? Thanks.
Comment 16 Harendra CLA 2011-04-20 03:52:17 EDT
(In reply to comment #13)
> (In reply to comment #12)
> > > However it was under different workspace,
> > > the javadoc was produced within that workspace as well. I checked html code
> > > there is no metadata mentioning utf-8. The DBCS characters are showing
> > > correctly.
> > But if you take the same workspace with each Eclipse version, is the behavior
> > different?
> Just confirmed, yes eclipse 3.6 can indeed open the problematic document
> without
> any problems. I will include settings too as it seems to be slightly different
> compared
> to 4.1. Either way I used default settings.

Ignore my settings remark, as you can see the setting in both the versions is exactly the same.
Comment 17 Harendra CLA 2011-04-20 03:54:25 EDT
(In reply to comment #15)
> > Either way I used default settings.
> What do you mean by "settings"? If you try with the identical workspace then no
> settings should be affected.
> 
> Also, could you please try with 3.7 (e.g. M6)? Thanks.

Tried on I20110310-1119 (3.7). Not working either.
Comment 18 Dani Megert CLA 2011-04-20 04:14:31 EDT
OK, I think the reason for the difference you see is that SWT uses WebKitGTK+ since 3.7 M1. I've filed bug 343349 for SWT to investigate this.
Comment 19 Dani Megert CLA 2011-04-20 10:22:38 EDT
Fixing this right is not possible since each project and even each source file can have a different encoding.