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 192174 - Project with encoding ISO-8859-15 shows files as UTF-8
Summary: Project with encoding ISO-8859-15 shows files as UTF-8
Status: RESOLVED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Editor (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Marek Fukala
URL:
Keywords: I18N
Depends on:
Blocks:
 
Reported: 2010-11-19 13:07 UTC by rizkit
Modified: 2010-11-26 06:13 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rizkit 2010-11-19 13:07:10 UTC
I've created projects under NetBeans 6.x with encoding ISO-8859-15 and html files inside the project were shown as ISO-8859-15 too. 
But with NetBeans 7.0 Beta (and NetBeans 7.0 M2) html files are randomly shown/edit as UTF-8 (visible in the file properties).


Product Version = NetBeans IDE 7.0 Beta (Build 201011152355)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_20
Runtime = Java HotSpot(TM) Client VM 16.3-b01
Comment 1 David Konecny 2010-11-21 20:30:51 UTC
Marek, could it be caused by your changes in supporting HTML5? If not please pass back to me and I will have a look. Thx.
Comment 2 Marek Fukala 2010-11-24 15:13:53 UTC
Html parsers doesn't influence the FEQ result at any way. I've looked at the issue and realized the behavior is caused by Tomas Zezula's FEQ performance optimalization before some time.

The problems happens only for file which doesn't specify its encoding either by BOM or by <meta> tag in the code. For such files the Html's FEQ returns UTF-8 instead of returning null and letting the other FEQ providers (mainly the project's one) to supply their values.

The issue is there due to the nature of the optimalization. At the beginning the FEQ always returns a proxy charset whith a patched decoder which then updates the encoding during the file content to chars conversion when the document is being loaded. To be able to do this lazy encoding detection, you need to return an instance of charset *with some encoding*. So the FEQ can never return null and hence work normally, e.g. fallback to the project's FEQ.
Comment 3 Tomas Zezula 2010-11-24 15:19:55 UTC
The possible solution is:

Charset getEncoding(...) {
if (threadLocalVariagle().get() == Boolean.TRUE) {
    //Ask by me, do nothing 
    return null;
}
...... //Current code
if (noEncodingFound) {
     threadLocalVariable.set(Boolean.TRUE);
     try {
     return FEQ.getEncoding();
     } finally {
        threadLocalVariable.remov();
     }
}
Comment 4 Marek Fukala 2010-11-24 15:24:41 UTC
Thanks. I was a bit afraid of calling back to the FEQ from inside it (not meaning the cycle - returning itself from within), but if you propose it I
Comment 5 Marek Fukala 2010-11-25 12:39:57 UTC
fixed in web-main#66987434fb83
Comment 6 Quality Engineering 2010-11-26 06:13:48 UTC
Integrated into 'main-golden', will be available in build *201011260001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/66987434fb83
User: Marek Fukala <mfukala@netbeans.org>
Log: #192174 - Project with encoding ISO-8859-15 shows files as UTF-8